Why is this submitting with full marks lol


#1

void Solution::merge(vector &a, vector &b) {
for(int i=0; i<b.size();i++)
a.push_back(b[i]);
sort(a.begin(), a.end());
}


#2

Cuz why not. it is abiding by the time limit. But that’s not the expected time complexity.


#3

Yeah exactly , why? The above one is acceptable but not this mentioned below:

int i=0,j=0;
while(i<A.size()&&j<B.size()){
    if(A[i]<=B[j])i++;
    else if(A[i]>=B[j]){
        A.insert(A.begin()+i,B[j]);
        j++;
    }

#4

because the time complexity of this one is m*n while of the upper one is (m+n)*log(m+n). In some cases, former can be lesser while in some cases later one depending on value distribution between m and n. Finally, it boils down to the values of m and n they are using for test cases.