A HACKERBREWERY ORIGINAL
Two queues, one counter
EasyArraysTwo pointers
Two baristas each have a queue of order numbers, sorted from smallest to largest. Merge the two queues into a new sorted array. Keep duplicates and return every order. Either queue may be empty.
Example 1
INPUT
[1,4,9], [2,4,8]OUTPUT[1,2,4,4,8,9]Compare the front of each queue and take the smaller order.
Example 2
INPUT
[], [3,7]OUTPUT[3,7]One queue is empty, so the other is already the answer.
Keep in mind
- 0 ≤ a.length, b.length ≤ 10,000
- Both arrays are sorted in nondecreasing order.
Draft saved on this browserSpaces: 2 UTF-8
INPUT
[1,4,9], [2,4,8]EXPECTED OUTPUT
[1,2,4,4,8,9]Public samples only. These checks do not award ranked points.