ALG-E012EasyTwo Pointers
Merge Two Sensor Logs
Merge two individually non-decreasing integer arrays into one non-decreasing array, keeping every occurrence.
Contract
input a: integer[]
input b: integer[]
return integer[]
Constraints
- • Both input arrays are sorted
- • 0 <= combined length <= 1000
Examples
Example 1
a = [1, 3, 5]
b = [2, 4]
→ [1, 2, 3, 4, 5]
Example 2
a = []
b = [3, 7]
→ [3, 7]
5 judge tests (2 shown above). Target complexity: O(m+n).