Editor

Python stack and queue problems

Last in, first out and first in, first out: stack and queue problems in Python, with tests that check your code.

Beginner

  1. 43. Hot PotatoPass it around the circle: who is the last one standing?40 XP8 min
  2. 48. Balanced BracketsDoes every bracket close in the right order?45 XP8 min
  3. 533. Binary by Stacking RemaindersTurn a whole number into ones and zeros the way a computer would30 XP5 min
  4. 564. Customers From One CityStack up the customer records for one city, then take them all off35 XP7 min
  5. 571. Reverse Each Word With a StackEvery word backwards, but the sentence still in its usual order35 XP6 min
  6. 577. Run the Stack CommandsPush, pop, peek and display on a pile of items40 XP8 min

Intermediate

  1. 63. Queue From Two StacksFirst in, first out, built from two last-in-first-out piles60 XP12 min
  2. 73. Reverse Polish CalculatorArithmetic with no brackets, where the operator comes last65 XP12 min
  3. 76. Tidy a File PathUntangle a folder path full of dots and extra slashes65 XP12 min
  4. 85. Stack With a MinimumA stack that always knows its smallest item70 XP12 min
  5. 96. Ring BufferA fixed-size queue that recycles its oldest slot75 XP15 min
  6. 103. Wait for a Warmer DayHow long until it gets warmer than today?80 XP15 min
  7. 595. Where the Brackets Go WrongPoint at the exact bracket that breaks the pattern65 XP12 min
  8. 599. Check and Evaluate PostfixWork out a postfix sum, or catch the ones that make no sense70 XP15 min
  9. 608. Undo the Spreadsheet EditsA spreadsheet that can take back every change, one at a time75 XP15 min
  10. 610. Infix to PostfixRewrite a formula so that every operator comes after its numbers90 XP18 min

Advanced

  1. 129. Function Time ProfilerHow much time did each function spend doing its own work?120 XP25 min
  2. 149. Smallest Number After DeletionsStrike out digits to make a number as small as possible135 XP25 min
  3. 170. Sum of Subarray MinimumsAdd up the smallest value of every stretch of a list165 XP35 min

Expert

  1. 178. Who Can See WhomA row of spectators, and how many each one can spot further along210 XP40 min
  2. 185. Largest Rectangle in a Bar ChartThe biggest billboard that fits against a city skyline230 XP45 min
  3. 435. Most Frequent StackA pile that hands back whatever it holds the most copies of200 XP35 min

Other topics

Or see every challenge, with study plans, today's challenge and duels.