Problem, as an interviewer would state it: "Merge two sorted arrays into one sorted array. Discuss edge cases, runtime, and how you would do it in place."
Examples:
merge([1, 3, 5], [2, 4, 6]); // [1, 2, 3, 4, 5, 6]
Clarifying questions expected:
- Sorted ascending? Numbers, or objects sorted by a key?
- On ties, which element should come first (does stability matter)?
- May I allocate a new array, or must it happen in place (LeetCode 88, where the first array has spare room at the end)?
Code / implementation expected: Yes — real, direct proof against a reference, plus stability and the in-place variant.