class Solution {
public:
void merge(int A[], int m, int B[], int n) {
if (m == 0) {
std::copy(B, B + n, A);
return ;
} else if (n ==0) {
return ;
}
std::copy(A, A + m, A + n);
int a = n, b = 0, fin = 0;
while (b < n && a < m + n) {
if (A[a] < B[b]) {
A[fin] = A[a];
++a;
} else {
A[fin] = B[b];
++b;
}
++fin;
}
while (b < n) {
A[fin] = B[b];
++b;
++fin;
}
while (a < m + n) {
A[fin] = A[a];
++a;
++fin;
}
}
};