Merge two sorted arrays in-place
Company: Meta
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates proficiency in array manipulation, in-place algorithms, and reasoning about time and space complexity when merging sorted sequences.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,2,3,None,None,None], 3, [2,5,6], 3)
Expected Output: [1, 2, 2, 3, 5, 6]
Explanation: Merge from the back into trailing slots.
Input: ([None], 0, [1], 1)
Expected Output: [1]
Explanation: Empty A prefix is supported.
Input: ([1], 1, [], 0)
Expected Output: [1]
Explanation: Empty B leaves A unchanged.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.