Very Understandable C++ solution


#1

void Solution::merge(vector &A, vector &B) {
int i=0,j=0;
int n1 = A.size(), n2=B.size();
vector c;

while(i+j < n1+n2)
{
    if(i==n1) c.push_back(B[j++]);
    else if(j == n2) c.push_back(A[i++]);
    else if(A[i] <= B[j]) c.push_back(A[i++]);
    else c.push_back(B[j++]);
}
A = c;

}