Easy · Arrays
Merge two sorted arrays
Given a sorted array a of length m + n whose first m entries are values (the last n are placeholders) and a sorted array b of n values, merge b into a in place so that a holds all m + n values in non-decreasing order; return nothing.
Examples
Example 1
[1,2,3,_,_,_] + [2,5,6]Output: [1, 2, 2, 3, 5, 6]
Example 2
[4,5,6,_,_] + [1,2]Output: [1, 2, 4, 5, 6]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.