I/P:
A: 1, 3,55,66,77,_,_,_
B:5,9,20
Have 3 variables pointing at
m = last index of A
n = last index of B
p = last index of A+B
A[m]>A[n]
-> A[p] = A[m]; m--; p--
else
-> A[p]=A[n]; n--; p--
run this till m and n becomes 0
liner time complexity
Mohit
On
Hi Guys ,
We have an array of size m+n in which m elements are
present in sorted order and other array of size n again in sorted order . We
want both of them to be sorted and present in first array.No third array is
supposed to be given.
like
1, 3,55,66,77,_,_,_