Queue LeetCode Problems: All 43, With Python Solutions

Every problem in this library that LeetCode tags Queue 43 in total, 34 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 43 problems
  • 7 Easy
  • 19 Medium
  • 17 Hard

How Queue problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Queue problems — each one explains the approach, gives a Python template and states its complexity.

  • Stack — When the most recent unresolved thing is the one that matters, use a stack.

Queue problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (7)

#ProblemDifficultyTopics
225Implement Stack using QueuesEasyStack, Design, Queue
232Implement Queue using StacksEasyStack, Design, Queue
387First Unique Character in a StringEasyQueue, Hash Table, String +1
933Number of Recent CallsEasyDesign, Queue, Data Stream
1700Number of Students Unable to Eat LunchEasyStack, Queue, Array +1
2073Time Needed to Buy TicketsEasyQueue, Array, Simulation
346Moving Average from Data StreamPremiumEasyDesign, Queue, Array +1

Medium (19)

#ProblemDifficultyTopics
341Flatten Nested List IteratorMediumStack, Tree, Depth-First Search +3
622Design Circular QueueMediumDesign, Queue, Array +1
641Design Circular DequeMediumDesign, Queue, Array +1
649Dota2 SenateMediumGreedy, Queue, String
918Maximum Sum Circular SubarrayMediumQueue, Array, Divide and Conquer +2
950Reveal Cards In Increasing OrderMediumQueue, Array, Sorting +1
1438Longest Continuous Subarray With Absolute Diff Less Than or Equal to LimitMediumQueue, Array, Ordered Set +3
1670Design Front Middle Back QueueMediumDesign, Queue, Array +2
1696Jump Game VIMediumQueue, Array, Dynamic Programming +2
1823Find the Winner of the Circular GameMediumRecursion, Queue, Array +2
2327Number of People Aware of a SecretMediumQueue, Dynamic Programming, Simulation
2526Find Consecutive Integers from a Data StreamMediumDesign, Queue, Hash Table +2
2762Continuous SubarraysMediumQueue, Array, Ordered Set +3
2944Minimum Number of Coins for FruitsMediumQueue, Array, Dynamic Programming +2
281Zigzag IteratorPremiumMediumDesign, Queue, Array +1
353Design Snake GamePremiumMediumDesign, Queue, Array +2
362Design Hit CounterPremiumMediumDesign, Queue, Array +2
379Design Phone DirectoryPremiumMediumDesign, Queue, Array +2
1429First Unique NumberPremiumMediumDesign, Queue, Array +2

Hard (17)

#ProblemDifficultyTopics
239Sliding Window MaximumHardQueue, Array, Sliding Window +2
862Shortest Subarray with Sum at Least KHardQueue, Array, Binary Search +4
936Stamping The SequenceHardStack, Greedy, Queue +1
995Minimum Number of K Consecutive Bit FlipsHardBit Manipulation, Queue, Array +2
1425Constrained Subsequence SumHardQueue, Array, Dynamic Programming +3
1499Max Value of EquationHardQueue, Array, Sliding Window +2
1687Delivering Boxes from Storage to PortsHardSegment Tree, Queue, Array +4
1825Finding MK AverageHardDesign, Queue, Data Stream +2
2071Maximum Number of Tasks You Can AssignHardGreedy, Queue, Array +4
2398Maximum Number of Robots Within BudgetHardQueue, Array, Binary Search +4
2407Longest Increasing Subsequence IIHardBinary Indexed Tree, Segment Tree, Queue +4
2444Count Subarrays With Fixed BoundsHardQueue, Array, Sliding Window +1
2528Maximize the Minimum Powered CityHardGreedy, Queue, Array +3
2945Find Maximum Non-decreasing Array LengthHardStack, Queue, Array +4
683K Empty SlotsPremiumHardBinary Indexed Tree, Segment Tree, Queue +5
2534Time Taken to Cross the DoorPremiumHardQueue, Array, Simulation
2969Minimum Number of Coins for Fruits IIPremiumHardQueue, Array, Dynamic Programming +2

When the Queue problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.