Solo practiceA little space to think.
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.
Your workspace
JavaScript
Draft saved on this browserSpaces: 2 UTF-8
Try an idea. See what happens.
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.

The vibe
Your problem set 2 selected

Local preview · up to 6 tabs in this browser

A perfect pairArrays · Hash mapsEasyKeep it togetherStrings · StacksEasyTwo queues, one counterArrays · Two pointersEasySomething differentStrings · Sliding windowMediumIslands in the brewGraphs · Depth-first searchMediumThe long way homeGraphs · Shortest pathsHard
HackerBrewery

This is an early, local preview. Create a room, open its link in another tab in this browser, and try a session together. Room chat and sample progress update between those tabs.

Links do not connect different devices yet. Networked rooms, WebRTC, accounts, and ranked judging are still being built. Sample checks are public practice checks, not ranked verdicts.

Choose the name other tabs in your local room will see.