Partially correct and Totally correct C++ solution


#1

Partial cases passed

auto it1 = A.begin();
auto it2 = B.begin();

while(it2 != B.end()){
    if(*it1 <= *it2 && it1!=A.end()) it1++;
    else if(*it1<=*it2 && it1==A.end()){
            A.push_back(*it2);
            it2++;
            it1++;
        }
    else{
        it1 = A.insert(it1,*it2);
        it1++;
        it2++;
    }
}

All cases passed

int i =A.size()-1,j =B.size()-1;
A.resize(A.size()+B.size());
int k = A.size()-1;

while(i>=0 && j>=0){
    if(A[i]>B[j]) A[k--] = A[i--];
    else A[k--] = B[j--];
}
while(i>=0) A[k--] = A[i--];
while(j>=0) A[k--] = B[j--];

#2

@kunal-katiyar Bro I’m still confused about Time complexity of the 2nd one even if got accepted xD