target only the first filled elements matter; after them there is a spare tail with room for exactly extra_len items (it holds zeros, which you should ignore). The array extra holds extra_len elements.
Move every element of extra into target so that the whole of target ends up sorted in non-decreasing order. Return the resulting target.
Try to do it in O(filled + extra_len) time with no extra array.target=[2, 6, 9, 0, 0], filled=3, extra=[4, 10], extra_len=2 → [2, 4, 6, 9, 10]
After the merge target becomes [2, 4, 6, 9, 10], and that is what you return.
target=[0, 0], filled=0, extra=[-3, 5], extra_len=2 → [-3, 5]
target has no elements of its own, so it simply receives extra: [-3, 5].
target=[1, 1, 7], filled=3, extra=[], extra_len=0 → [1, 1, 7]
filled elements of target and all of extra are sorted in non-decreasing ordertarget=[2, 6, 9, 0, 0], filled=3, extra=[4, 10], extra_len=2
[2, 4, 6, 9, 10]
Run checks the first 3 tests in your browser. Submit checks all 38 tests on the server, hidden ones included.