- 思路很简单,把B塞到A里,然后对A进行sort就行
class Solution { public: void merge(int A[], int m, int B[], int n) { int i, j; j = 0; for (i = m; i < m + n; i++) { A[i] = B[j]; j++; } sort(A, A + m + n); } };
class Solution { public: void merge(int A[], int m, int B[], int n) { int i, j; j = 0; for (i = m; i < m + n; i++) { A[i] = B[j]; j++; } sort(A, A + m + n); } };