You are given two sorted arrays, a[] and b[], both arranged in non-decreasing order. The task is to merge these arrays into a single sorted array without using extra space. Modify a so that it contains the first n elements and modify b so that it contains the last m elements.
Example 1
Input: a[] = [2, 4, 7, 10], b[] = [2, 3]
Output: 2 2 3 4 7 10
Explanation: After merging the two non-decreasing arrays, we get, 2 2 3 4 7 10
Example 2
Input: a[] = [1, 5, 9, 10, 15, 20], b[] = [2, 3, 8, 13]
Output: 1 2 3 5 8 9 10 13 15 20
Explanation: After merging two sorted arrays we get 5 10 12 18 20.
Sign in to write, run, and submit your solution against the full test suite.