class Solution {
public:
    void merge(int A[], int m, int B[], int n) {
        int i=0,j=0,k=0;
        int *C = new int[m+n];
        while(i<m&&j<n){
            int min = A[i]<B[j]?A[i]:B[j];
            A[i]<B[j]?++i:++j;
            C[k++] = min;
        }
        while(i<m) C[k++] = A[i++];
        while(j<n) C[k++] = B[j++];
        memcpy(A, C, (m+n)*sizeof(int));
    }
};