Stacks and queues interview questions

Stacks for matching and undo, queues for order of arrival, monotonic stacks for 'next bigger' questions, and how to build one from the other.

5 quick facts

– interview-ready · 12 questions in this topic

– of 12 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. Do the brackets in a line balance?Predict
  2. How many days until a warmer day?Pick the fix
  3. A stack that also reports its minimumPredict
  4. Evaluate an expression written in postfix orderPredict
  5. Apply the backspaces in typed textPredict
  6. Build a queue out of two stacksPredict
  7. Tidy a file path with . and .. partsPredict
  8. Largest poster that fits under a skylinePredict
  1. How many requests arrived in the recent window?Fill the blank
  2. Stack or queue: LIFO and FIFOPredict
  3. The monotonic stack patternPredict
  4. Recursion is a stack: converting to an explicit onePredict

Practise this topic

Flashcards · 22

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 12 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license