DSAWiser

DSA question set · 180 questions

Queue DSA Practice Questions

Explore 180 DSA questions in Queue. Practice with DSAWiser’s code editor and visualizer.

QueueGraphNetwork FlowBreadth-First SearchDequeMonotonic QueueHeapShortest PathGame TheoryBinary SearchLongest Increasing SubsequenceTrieBit ManipulationFenwick TreeOrder StatisticsTreeDynamic Programming

What’s in this set

The Queue collection contains 180 problems: 43 basic, 36 easy, 56 medium, 37 hard, 8 very hard. Choose a question at your current level, or follow the collection’s order below.

Topics in this collection include Queue, Graph, Network Flow, Breadth-First Search, Deque. Each question shows its own topics and difficulty so you can decide where to begin.

Practice with the code visualizer

  1. Open a question in the editor and read the statement, inputs, and expected output. Predict the result for a small example before writing code.
  2. Write a solution and run the examples. If a result differs from your prediction, reduce the input until you can follow each step.
  3. Step through your code in the visualizer. Use a breakpoint to inspect the state at a specific line, then compare it with your reasoning.

Questions in this set

180 total

Open a question in the editor to read its statement and examples. Sign in to practice.

  1. Queue FIFO Enqueue and Dequeue SequenceQueueBasic
  2. Peek / Front ElementQueueBasic
  3. Queue IsEmpty and Size StateQueueBasic
  4. Queue Underflow CheckQueue · Graph · Network FlowBasic
  5. Array-Based Queue Front and Rear PointersQueueBasic
  6. Queue Overflow Detection (Fixed Capacity)Queue · Graph · Network FlowBasic
  7. Sum and Average of Queue ElementsQueueBasic
  8. Count Occurrences of Target in QueueQueueBasic
  9. Find Minimum and Maximum in QueueQueueBasic
  10. Split Queue Elements at Odd and Even PositionsQueueBasic
  11. Check if Two Queues are IdenticalQueueBasic
  12. Circular Queue Index CalculationQueueBasic
  13. Copy Queue ContentsQueueBasic
  14. Reverse a Queue Using an Auxiliary StackQueueBasic
  15. Queue Rotation by One PositionQueueBasic
  16. Queue Rotation by K PositionsQueueBasic
  17. Count Elements Greater Than a ThresholdQueueBasic
  18. Remove All Occurrences of a Target ValueQueueBasic
  19. Interleave Two Queues of Equal SizeQueueBasic
  20. Front and Rear InspectionQueueBasic
  21. Queue Size After Batch OperationsQueueBasic
  22. Check if Queue is SortedQueueBasic
  23. Replace Negative Elements with ZeroQueueBasic
  24. Reverse the First K Elements of a QueueQueueBasic
  25. Concatenate Two QueuesQueueBasic
  26. Count Distinct Elements in QueueQueueBasic
  27. Double-Ended Queue (Deque) OperationsQueueBasic
  28. Find 1-Based Index of First OccurrenceQueueBasic
  29. Circular Queue Full and Empty StatusQueueBasic
  30. Check if Queue is a PalindromeQueueBasic
  31. Middle Element(s) of a QueueQueueBasic
  32. Remove Every Second ElementQueueBasic
  33. First-Come, First-Served (FCFS) Print QueueQueueBasic
  34. Separate Even and Odd Elements into Two QueuesQueueBasic
  35. Count Elements Ahead in QueueQueueBasic
  36. Reverse the Last K Elements of a QueueQueueBasic
  37. Frequency of the Front ElementQueueBasic
  38. Delete Minimum Element from QueueQueueBasic
  39. Check if Two Queues are Mutual ReversesQueueBasic
  40. Circular Queue Size from Front and Rear PointersQueueBasic
  41. Filter Multiples of K from QueueQueueBasic
  42. Move All Zeros to the Rear of QueueQueueBasic
  43. Sort Queue Elements in Non-Decreasing OrderQueueBasic
  44. Queue Using Two Stacks SimulationQueueEasy
  45. Merge Two Sorted QueuesQueueEasy
  46. Generate Binary Numbers from 1 to N Using a QueueQueueEasy
  47. Circular Queue Array StateQueueEasy
  48. Interleave First Half and Second HalfQueueEasy
  49. Round-Robin Queue Service SimulationQueueEasy
  50. Stack Using Two Queues SimulationQueueEasy
  51. Number of Recent Calls (Ping Counter)QueueEasy
  52. Time Needed to Buy TicketsQueueEasy
  53. Number of Students Unable to Eat LunchQueueEasy
  54. Moving Average from Data StreamQueueEasy
  55. First Unique Character in a StreamQueueEasy
  56. Design Circular QueueQueueEasy
  57. Design Circular DequeQueueEasy
  58. Implement Queue Using StacksQueueEasy
  59. Implement Stack Using QueuesQueueEasy
  60. Binary Tree Level Order TraversalQueue · Breadth-First Search · GraphEasy
  61. Minimum Depth of Binary Tree via BFSQueue · Breadth-First Search · GraphEasy
  62. Symmetric Tree Check via QueueQueue · Breadth-First Search · GraphEasy
  63. Cousins in Binary TreeQueue · Breadth-First Search · GraphEasy
  64. Average of Levels in Binary TreeQueue · Breadth-First Search · GraphEasy
  65. Flood Fill via Queue BFSQueue · Breadth-First Search · GraphEasy
  66. Hot Potato (Josephus Elimination) via QueueQueueEasy
  67. Shortest Path in Unweighted Grid via BFSQueue · Breadth-First Search · GraphEasy
  68. Design Hit CounterQueueEasy
  69. Card Game War SimulationQueueEasy
  70. Deepest Leaves Sum via BFSQueue · Breadth-First Search · GraphEasy
  71. Largest Value in Each Tree RowQueue · Breadth-First Search · GraphEasy
  72. VIP vs Regular Queue ServiceQueueEasy
  73. First Negative Integer in Every Window of Size KQueueEasy
  74. Find Bottom-Left Tree Value via BFSQueue · Breadth-First Search · GraphEasy
  75. Winner of the Circular Elimination GameQueueEasy
  76. Keys and Rooms (BFS Graph Reachability)Queue · Breadth-First Search · GraphEasy
  77. Flatten 2D Vector via Queue of QueuesQueueEasy
  78. BFS Traversal of an Undirected GraphQueue · Breadth-First Search · GraphEasy
  79. Maximum Level Sum of a Binary TreeQueue · Breadth-First Search · GraphEasy
  80. Reveal Cards in Increasing OrderQueueMedium
  81. Dota2 SenateQueueMedium
  82. Binary Tree Right Side ViewQueue · Breadth-First Search · GraphMedium
  83. N-ary Tree Level Order TraversalQueue · Breadth-First Search · GraphMedium
  84. 0-1 Matrix Distance to Nearest ZeroQueueMedium
  85. Rotting Oranges (Multi-Source BFS)Queue · Breadth-First Search · GraphMedium
  86. Binary Tree Zigzag Level Order TraversalQueue · Breadth-First Search · GraphMedium
  87. Sliding Window Minimum of Size KQueue · Deque · Monotonic QueueMedium
  88. Sliding Window Maximum of Size KQueue · Deque · Monotonic QueueMedium
  89. Task Scheduler Execution via Cooldown QueueQueueMedium
  90. Number of Islands via BFSQueue · Breadth-First Search · GraphMedium
  91. Stack Permutation Check via QueueQueueMedium
  92. Nearest Exit from Entrance in MazeQueue · Breadth-First Search · GraphMedium
  93. Design Front-Middle-Back QueueQueueMedium
  94. Minimum Knight Moves via BFSQueue · Breadth-First Search · GraphMedium
  95. Open the Lock (State-Space BFS)Queue · Breadth-First Search · GraphMedium
  96. Jump Game III (Reach Zero via BFS)Queue · Breadth-First Search · GraphMedium
  97. Minimum Operations to Transform Number via BFSQueue · Breadth-First Search · GraphMedium
  98. Snakes and Ladders Board Game via BFSQueue · Breadth-First Search · GraphMedium
  99. Shortest Bridge Between Two Islands via Multi-Source BFSQueue · Breadth-First Search · GraphMedium
  100. Longest Continuous Subarray With Absolute Diff Within LimitQueueMedium
  101. Jump Game VI (DP with Monotonic Deque)Queue · Deque · Monotonic QueueMedium
  102. Course Schedule (Kahn's In-Degree Queue)QueueMedium
  103. Course Schedule II (Topological Order Generation)QueueMedium
  104. Shortest Path with Alternating ColorsQueueMedium
  105. Minimum Height Trees (Leaf-Trimming via Queue)Queue · Breadth-First Search · GraphMedium
  106. Shortest Path Graph Construction via BFS (Word Ladder Metric)Queue · Breadth-First Search · GraphMedium
  107. As Far from Land as Possible (Multi-Source BFS)Queue · Breadth-First Search · GraphMedium
  108. All Nodes Distance K in Binary TreeQueue · Breadth-First Search · GraphMedium
  109. Bus Routes (BFS on Route Network)Queue · Breadth-First Search · GraphMedium
  110. Pacific Atlantic Water Flow (Dual Multi-Source BFS)Queue · Graph · Network FlowMedium
  111. Minimum Jumps to Reach Home with State QueueQueueMedium
  112. Shortest Path to Get FoodQueue · Breadth-First Search · GraphMedium
  113. Maximum of Minimum Values for Every Window SizeQueue · Deque · Monotonic QueueMedium
  114. Alien Dictionary (Kahn's Topological Sort Queue)QueueMedium
  115. Clone Graph via BFS QueueQueue · Breadth-First Search · GraphMedium
  116. Surrounded Regions (Boundary Multi-Source BFS)Queue · Breadth-First Search · GraphMedium
  117. Constrained Subsequence Sum (DP with Monotonic Deque)Queue · Deque · Monotonic QueueMedium
  118. Sequence Reconstruction (Unique Topological Sort Check)QueueMedium
  119. Minimum Genetic Mutation via State BFSQueue · Breadth-First Search · GraphMedium
  120. Parallel Courses (Semester Count via Kahn's BFS)Queue · Breadth-First Search · GraphMedium
  121. Minimum Flips to Convert Binary Matrix to Zero MatrixQueueMedium
  122. Word Break Sentence Segmentation via BFS QueueQueue · Breadth-First Search · GraphMedium
  123. Find All Groups of Farmland via BFSQueue · Breadth-First Search · GraphMedium
  124. Smallest String With Swaps (Connected Components via BFS Queue)Queue · Breadth-First Search · GraphMedium
  125. Sliding Puzzle (2x3 Permutation BFS)Queue · Breadth-First Search · GraphMedium
  126. Swim in Rising Water (Min-Max Priority Queue BFS)Queue · Heap · Shortest Path · GraphMedium
  127. Parallel Courses III (Critical Path via Kahn's In-Degree Queue)QueueMedium
  128. Cheapest Flights Within K Stops (Level-Constrained BFS Queue)Queue · Breadth-First Search · GraphMedium
  129. Maximum Subarray Sum with Length in [L, R] (Monotonic Deque)Queue · Deque · Monotonic QueueMedium
  130. Shortest Path in Grid with Teleporters (0-1 BFS)Queue · Breadth-First Search · GraphMedium
  131. Shortest Cycle in an Undirected Graph (Multi-Root BFS Queue)Queue · Breadth-First Search · GraphMedium
  132. Shortest Path with Minimum Turns in a Grid (0-1 BFS)Queue · Breadth-First Search · GraphMedium
  133. Longest Cycle in a Directed Graph (Kahn's Queue In-Degree Elimination)Queue · Breadth-First Search · GraphMedium
  134. Shortest Path with Periodic Traffic Signals (Priority Queue BFS)Queue · Heap · Shortest Path · GraphMedium
  135. Scheduled Transit Network Routing (Event-Driven Priority Queue)Queue · Heap · Shortest Path · GraphMedium
  136. Word Ladder Shortest Transformation via BFSQueue · Breadth-First Search · GraphHard
  137. 0-1 BFS in a Direction GridQueue · Breadth-First Search · GraphHard
  138. Shortest Path to Get All Keys (Bitmask State BFS)Queue · Breadth-First Search · GraphHard
  139. Shortest Path in a Grid with Obstacle EliminationQueueHard
  140. Shortest Path Visiting All Nodes (Multi-Source Bitmask BFS)Queue · Breadth-First Search · GraphHard
  141. Cut Off Trees for Golf Event (Chained BFS)Queue · Breadth-First Search · GraphHard
  142. Shortest Subarray with Sum at Least K (Monotonic Deque)Queue · Deque · Monotonic QueueHard
  143. Minimum Cost to Reach Destination in TimeQueueHard
  144. Escape a Large Maze (Bounded BFS Queue)Queue · Breadth-First Search · GraphHard
  145. Trapping Rain Water II (Priority Queue 2D Boundary BFS)Queue · Heap · Shortest Path · GraphHard
  146. Sliding Window Median (Dual Balanced Priority Queues)Queue · Heap · Shortest Path · GraphHard
  147. Minimum Moves to Move a Box to Target (Push Box)QueueHard
  148. Sort Items by Groups Respecting DependenciesQueueHard
  149. Delivering Boxes from Storage to Ports (DP + Monotonic Deque)Queue · Deque · Monotonic QueueHard
  150. Minimum Reverse Operations (Parity-Set BFS Queue)Queue · Breadth-First Search · GraphHard
  151. The Maze III (Rolling Ball with Lexicographical Shortest Path)Queue · Breadth-First Search · GraphHard
  152. Strange Printer II (Bounding Box Dependency Queue)QueueHard
  153. Build a Matrix With Conditions (2D Dual Topological Sort)QueueHard
  154. Reachable Nodes in Subdivided Graph (Priority Queue BFS)Queue · Heap · Shortest Path · GraphHard
  155. All Shortest Paths via Bidirectional BFS (Word Ladder Reconstruction)Queue · Breadth-First Search · GraphHard
  156. Shortest Walk Distance from All Buildings (Repeated BFS)Queue · Breadth-First Search · GraphHard
  157. Race Car State-Space BFSQueue · Breadth-First Search · GraphHard
  158. Shortest Path with Electric Vehicle Battery ConstraintQueueHard
  159. Cat and Mouse (Retrograde Analysis via In-Degree Queue)Queue · Game Theory · GraphHard
  160. Minimum Insertions for a Target Subsequence (LIS and Binary Search)Queue · Binary Search · Longest Increasing SubsequenceHard
  161. Minimum Moves to Reach Target with Rotations (Snake BFS)Queue · Breadth-First Search · GraphHard
  162. Critical Path and Project Duration in DAG (Kahn's Queue)QueueHard
  163. 2D Monotonic Deque for Submatrix Maxima in O(M × N)Queue · Deque · Monotonic QueueHard
  164. Maximum Subarray XOR with Length in [L, R] (Trie + Sliding Window Queue)Queue · Trie · Bit ManipulationHard
  165. Shortest Path with Dynamic Fuel Recharging and Variable PricingQueue · Heap · Shortest Path · GraphHard
  166. Dial's Algorithm for 0-K Integer Weighted Shortest PathsQueueHard
  167. Sliding Window X-th Smallest Element (Fenwick Tree and FIFO Eviction)Queue · Fenwick Tree · Order StatisticsHard
  168. Maximum Weight Distance-Separated Tree Subset (Tree DP)Queue · Tree · Dynamic ProgrammingHard
  169. Shortest Common Superstring (Bitmask Priority Queue BFS)Queue · Heap · Shortest Path · GraphHard
  170. Slope Trick for Optimal Monotonic Sequence (Priority Queue)Queue · Heap · Dynamic ProgrammingHard
  171. Shortest Weighted Path with At Most K Reverse Traversals (State Dijkstra)Queue · Breadth-First Search · GraphHard
  172. Feasible Circulation with Demands via Dinic's BFS QueueQueue · Graph · Network FlowHard
  173. Cat and Mouse II (Grid Retrograde In-Degree Queue)Queue · Game Theory · GraphVery hard
  174. Escape the Spreading Fire with Maximum Safe DelayQueueVery hard
  175. FIFO Push-Relabel Maximum Flow AlgorithmQueue · Graph · Network FlowVery hard
  176. Multi-Box Sokoban (Dual Box Nested BFS)Queue · Breadth-First Search · GraphVery hard
  177. Dinic's Algorithm for Maximum Flow (BFS Level Graph)Queue · Graph · Network FlowVery hard
  178. 15-Puzzle Solvability and Frontier Queue SearchQueueVery hard
  179. Suurballe's Algorithm for Two Edge-Disjoint Shortest PathsQueue · Graph · Network FlowVery hard
  180. Movable Bridges Multi-State BFSQueue · Breadth-First Search · GraphVery hard