Two PointersEasy

Merge Sorted Array

first and second are both sorted from small to large. Return one sorted list with all their numbers, in O(n + m) time.

Example 1first = [1, 4, 7], second = [2, 3, 9] → [1, 2, 3, 4, 7, 9]
Example 2first = [], second = [5] → [5]
0 ≤ n, m ≤ 10⁴ · both lists sorted

Hints

0 of 3 open
Hint 2 · the patternHint 3 · the key line