Given two sorted integer arrays arr1
and arr2
where length of arr1
is equal or larger than length of arr2
. The array arr1
has exactly x
vacant cells, which is equal to the difference in length between two arrays. Merge the elements of arr2
in their correct position in array arr1
and return the final array.
Let array arr1
equal to [ 0, 2, 0, 3, 0, 5, 6, 0, 0 ]
and array arr2
equal to [ 1, 8, 9, 10, 15 ]
.
The vacant cells in arr1
are represented by 0
. After we merge arr2
into arr1
the expected array is [ 1, 2, 3, 5, 6, 8, 9, 10, 15 ]
. The solution is expected to return this array.