LeetCode面试题 10.01. 合并排序的数组
class Solution {
public:
void merge(vector<int>& A, int m, vector<int>& B, int n) {
int i = m - 1;
int j = n - 1;
int it = m + n - 1;
while (i >= 0 && j >= 0)
if (A[i] > B[j]) A[it--] = A[i--];
else A[it--] = B[j--];
while (i >= 0) A[it--] = A[i--];
while (j >= 0) A[it--] = B[j--];
}
};