[C++][Merge Two Sorted Lists II]


#1
void Solution::merge(vector<int> &A, vector<int> &B) {
    vector<int> C;
    auto it1 = A.begin(), it2 = B.begin();
    while(it1 != A.end() || it2 != B.end()) {
        int val1 = INT_MAX, val2 = INT_MAX;
        if(it1 == A.end())              C.push_back(*it2++);
        else if(it2 == B.end())         C.push_back(*it1++);
        else if(*it1 < *it2)            C.push_back(*it1++);
        else                            C.push_back(*it2++);
    }
    swap(A, C);
}