Partially correct.failing for large test cases


#1

void Solution::merge(vector &A, vector &B) {
int i=0,j=0;
vector ans;
while(i<A.size()&&j<B.size())
{
if(A[i]>B[j]){
ans.push_back(B[j]);
j++;}
else if(A[i]<B[j])
{
ans.push_back(A[i]);
i++;
}
else
{
ans.push_back(A[i]);
ans.push_back(A[j]);
i++;
j++;
}
}
while(i<A.size())
{
ans.push_back(A[i]);
i++;
}
while(j<B.size())
{
ans.push_back(B[j]);
j++;
}
A=ans;
}

whats the mistake.