class Solution { public: void merge(int A[], int m, int B[], int n) { int a = m-1; int b = n-1; int right = m + n - 1; while(a>=0 && b>=0) { if(A[a] >= B[b]) { A[right] = A[a]; a--; } else { A[right] = B[b]; b--; } right--; } while(b>=0) { A[right] = B[b]; b--; right--; } } };
解题思路:双指针