DSAWiser

DSA question set · 172 questions

Deque DSA Practice Questions

Explore 172 DSA questions in Deque. Practice with DSAWiser’s code editor and visualizer.

DequeDeque techniquesDeque operations and sequence drillsQueue applicationsStackComplete deque operation harnessPalindrome with one deletion / two pointersAdjacent-pair string reductionBackspace simulationWindow candidate queueDiscard/rotate simulationScore record simulationCase-pair reductionStable parity interleavingFixed-window running sumTarget-pair reductionRelated algorithmsDirectory depth counterStreaming uniqueness / FIFO candidatesNext smaller-or-equal discountNext greater elementDepth counterJosephus simulationQueue rotation / preference countsMoving average / running sumTicket round-robin simulationVowel reversal / two pointersGreedy bill countersInterval union in sorted orderCircular deque designTree zigzag level traversalBalanced middle queueReverse reveal simulationMonotonic sliding minimumMonotonic sliding maximumHistory cursor / two stacksStack permutation validationPath component normalization0-1 weighted grid BFSChampion simulation with large-K shortcutFrequency pairing / palindrome constructionRPN evaluationNext warmer dayCollision resolutionAggregated monotonic spanParenthesis scoringGreedy digit removalCircular next greater elementStrict colder-prefix spanTwo-party scheduling / dual FIFOTree right view BFSArithmetic precedence evaluationDual monotonic sliding extremaSliding maximum DP / Jump Game VIObstacle-entry 0-1 BFSSubarray contributions / tie spansSum of max/min contributionsCount bounded-range windowsExpression precedenceGraph 0-1 BFSEndpoint minimax interval DPCursor editing / two dequesSorted-prefix/suffix mergingSorted arrival-time greedy132 pattern invariantMin-cost leaf tree / greedy stack or DPCompetitive subsequence greedyDistinct-character subsequence (duplicate)Path-depth parsingRotation + alternating-pattern windowSerialization slot counter / reductionReverse-edge 0-1 BFSCandidate-prefix maximum widthCircular bounded-length prefix minimaNested string parser (duplicate)Bounded-length prefix minimumLast-valid-bound positionsAt-most distinct window countingCartesian tree / monotonic spine stackCompressed subarray OR statesFrequency window with capped multiset matchesCompressed subarray GCD statesBounded-choice interval game DPDirectional-grid 0-1 BFSAll-window min spans / propagationMinimum-times-length with anchorRestartable sliding maximum DPVisibility / decreasing stackSimultaneous-deletion roundsRainwater / stack or two pointersHistogram nearest-smaller spansRow histograms / maximal rectangleFrequency buckets / recency stackNearest-smaller span thresholdBinary search + pill-assignment greedy dequeNegative-prefix shortest subarrayPolar angles / circular sorted windowShortest word-graph path countingCapacity window + transformed DPSliding median / ordered multisetsEquation rearrangement + window maximumKey-mask state-space BFSRestriction propagation / interval peaksEqual-word-length frequency windowsSubsequence matching windowsForward grid jumps / efficient reachabilityTransformed DP + Fenwick/segment treeMerged K-list covering windowRoute-stop BFSNested chemical grammar / mapsUnique sorted range windowMinimax elevation pathMulti-source visited-mask BFSDinic flow / residual BFS + blocking DFSThree-window prefix/suffix DP2D compression + prefix frequencyCircular dial DPMonotonic convex hull DPResidue-class bounded knapsack windowsTwo-phase portal 0-1 state BFSSliding XOR binary trieDuplicate substrings / suffix or hash searchMerge inversion / count-smallerBox/player reachability state BFSRow-pair compression + dual dequesMonotone decision-interval DPHighest-label push-relabel max flowL1 isotonic regression / slope trick heapLong-path tree depth-profile mergingWQS + monotonic hull partition DPPersistent range maximum with FIFO state checkpointsCapacity-aware associative segment summaries

What’s in this set

The Deque collection contains 172 problems: 47 basic, 22 easy, 54 medium, 42 hard, 7 very hard. Choose a question at your current level, or follow the collection’s order below.

Topics in this collection include Deque, Deque techniques, Deque operations and sequence drills, Queue applications, Stack. 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

172 total

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

  1. Deque Four Core Operations SequenceDeque · Deque techniques · Deque operations and sequence drillsBasic
  2. Peek Front and Peek BackDeque · Deque techniques · Deque operations and sequence drillsBasic
  3. Deque Underflow DetectionDeque · Deque techniques · Deque operations and sequence drillsBasic
  4. Deque Size and Emptiness StatusDeque · Deque techniques · Deque operations and sequence drillsBasic
  5. Circular Array Deque Pointer WraparoundDeque · Deque techniques · Deque operations and sequence drillsBasic
  6. Bounded Deque Overflow and UnderflowDeque · Deque techniques · Deque operations and sequence drillsBasic
  7. Palindrome Verification via DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
  8. Sequence Inversion via Front EnqueueDeque · Deque techniques · Deque operations and sequence drillsBasic
  9. Deque Rotation by One Position (Left and Right)Deque · Deque techniques · Deque operations and sequence drillsBasic
  10. Deque Element Statistics: Sum, Min, and MaxDeque · Queue applications · Deque operations and sequence drillsBasic
  11. Check if Two Deques are IdenticalDeque · Queue applications · Deque operations and sequence drillsBasic
  12. Deque Multi-Step Rotation by K PositionsDeque · Deque techniques · Deque operations and sequence drillsBasic
  13. Swap Front and Back ElementsDeque · Deque techniques · Deque operations and sequence drillsBasic
  14. Alternating Ends Insertion (Zigzag Push)Deque · Deque techniques · Deque operations and sequence drillsBasic
  15. Alternating Ends Extraction (Zigzag Pop)Deque · Deque techniques · Deque operations and sequence drillsBasic
  16. Count Target Occurrences in DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  17. Distance from Front and Distance from BackDeque · Queue applications · Deque operations and sequence drillsBasic
  18. Delete All Occurrences of Target from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  19. Duplicate Deque (Preserve Front and Back Order)Deque · Deque techniques · Deque operations and sequence drillsBasic
  20. Concatenate Two Deques (Append to Back)Deque · Deque techniques · Deque operations and sequence drillsBasic
  21. Prepend One Deque to Another (Prepend to Front)Deque · Deque techniques · Deque operations and sequence drillsBasic
  22. Check if Deque Elements are SortedDeque · Queue applications · Deque operations and sequence drillsBasic
  23. Reverse the First K Elements of a DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
  24. Reverse the Last K Elements of a DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
  25. Doubly Linked List Deque Traversal (Forward and Backward)Deque · Deque techniques · Deque operations and sequence drillsBasic
  26. Count Unique Elements in DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  27. Split Deque into Two HalvesDeque · Deque techniques · Deque operations and sequence drillsBasic
  28. Interleave First Half and Second HalfDeque · Deque techniques · Deque operations and sequence drillsBasic
  29. Partition Evens to Front and Odds to BackDeque · Deque techniques · Deque operations and sequence drillsBasic
  30. Partition Negatives to Front and Positives to BackDeque · Deque techniques · Deque operations and sequence drillsBasic
  31. Middle Element(s) of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  32. Delete Middle Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  33. Remove Every Second Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  34. Outside-In Pair SumsDeque · Deque techniques · Deque operations and sequence drillsBasic
  35. Stack Using Deque OperationsDeque · Stack · Deque operations and sequence drillsBasic
  36. Queue Using Deque OperationsDeque · Deque techniques · Deque operations and sequence drillsBasic
  37. Reverse First K and Last K Elements of DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
  38. Filter Multiples of K from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  39. Delete Minimum Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  40. Delete Maximum Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  41. Train Shunting Yard SimulationDeque · Deque techniques · Deque operations and sequence drillsBasic
  42. Check for Alternating SignsDeque · Queue applications · Deque operations and sequence drillsBasic
  43. Sort Deque Elements in Non-Decreasing OrderDeque · Queue applications · Deque operations and sequence drillsBasic
  44. Move All Zeros to the Back of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  45. Move All Zeros to the Front of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
  46. Circular Array Deque Physical Slots and PointersDeque · Deque techniques · Deque operations and sequence drillsBasic
  47. Complete Double-Ended Queue Operations HarnessDeque · Deque techniques · Complete deque operation harnessBasic
  48. Valid Palindrome After at Most One DeletionDeque · Queue applications · Palindrome with one deletion / two pointersEasy
  49. Remove All Adjacent Duplicates Using a DequeDeque · Stack · Adjacent-pair string reductionEasy
  50. Backspace String CompareDeque · Stack · Backspace simulationEasy
  51. First Negative Integer in Every Window of Size KDeque · Deque techniques · Window candidate queueEasy
  52. Card Discard and Cycle GameDeque · Deque techniques · Discard/rotate simulationEasy
  53. Baseball Game Score TrackingDeque · Stack · Score record simulationEasy
  54. Make The String Great (Adjacent Case Elimination)Deque · Stack · Case-pair reductionEasy
  55. Parity Interleaving via DequesDeque · Deque techniques · Stable parity interleavingEasy
  56. Maximum Sum in a Sliding Window of Size KDeque · Queue applications · Fixed-window running sumEasy
  57. Minimum String Length After Removing Target SubstringsDeque · Stack · Target-pair reductionEasy
  58. Crawler Log Folder DepthDeque · Related algorithms · Directory depth counterEasy
  59. First Unique Character in Stream via Candidate DequeDeque · Deque techniques · Streaming uniqueness / FIFO candidatesEasy
  60. Final Prices With a Special Discount (Monotonic Stack)Deque · Stack · Next smaller-or-equal discountEasy
  61. Next Greater Element I (Monotonic Stack)Deque · Stack · Next greater elementEasy
  62. Maximum Nesting Depth of ParenthesesDeque · Related algorithms · Depth counterEasy
  63. Winner of Circular Game via Deque ShiftsDeque · Deque techniques · Josephus simulationEasy
  64. Student Cafeteria Queue Simulation via DequeDeque · Queue applications · Queue rotation / preference countsEasy
  65. Moving Average from Data Stream via DequeDeque · Deque techniques · Moving average / running sumEasy
  66. Ticket Counter Purchase Time via Deque SimulationDeque · Deque techniques · Ticket round-robin simulationEasy
  67. Reverse Vowels of a StringDeque · Related algorithms · Vowel reversal / two pointersEasy
  68. Lemonade ChangeDeque · Related algorithms · Greedy bill countersEasy
  69. Poison Duration Interval TrackingDeque · Related algorithms · Interval union in sorted orderEasy
  70. Design Circular DequeDeque · Deque techniques · Circular deque designMedium
  71. Binary Tree Zigzag Level Order Traversal via DequeDeque · Queue applications · Tree zigzag level traversalMedium
  72. Design Front-Middle-Back Queue via Two DequesDeque · Deque techniques · Balanced middle queueMedium
  73. Reveal Cards in Increasing Order via DequeDeque · Deque techniques · Reverse reveal simulationMedium
  74. Sliding Window Minimum via Monotonic DequeDeque · Deque techniques · Monotonic sliding minimumMedium
  75. Sliding Window Maximum via Monotonic DequeDeque · Deque techniques · Monotonic sliding maximumMedium
  76. Browser History Navigation via DequeDeque · Queue applications · History cursor / two stacksMedium
  77. Validate Stack Sequences SimulationDeque · Stack · Stack permutation validationMedium
  78. Simplify Canonical Unix PathDeque · Stack · Path component normalizationMedium
  79. Basic 0-1 BFS in a Weighted GridDeque · Deque techniques · 0-1 weighted grid BFSMedium
  80. Winner of an Array Game with Consecutive RoundsDeque · Deque techniques · Champion simulation with large-K shortcutMedium
  81. Longest Palindrome from Two-Letter WordsDeque · Related algorithms · Frequency pairing / palindrome constructionMedium
  82. Evaluate Reverse Polish NotationDeque · Stack · RPN evaluationMedium
  83. Daily Temperatures Waiting Days (Monotonic Stack)Deque · Stack · Next warmer dayMedium
  84. Asteroid Collision SimulationDeque · Stack · Collision resolutionMedium
  85. Online Stock Span (Monotonic Stack)Deque · Stack · Aggregated monotonic spanMedium
  86. Score of ParenthesesDeque · Stack · Parenthesis scoringMedium
  87. Remove K Digits to Minimize Value via Monotonic StackDeque · Stack · Greedy digit removalMedium
  88. Next Greater Element in a Circular Array (Monotonic Stack)Deque · Stack · Circular next greater elementMedium
  89. Days with Strictly Lower Temperatures via Monotonic StackDeque · Stack · Strict colder-prefix spanMedium
  90. Dota2 Senate Voting Simulation via Dual DequesDeque · Deque techniques · Two-party scheduling / dual FIFOMedium
  91. Binary Tree Right Side View via Level DequeDeque · Queue applications · Tree right view BFSMedium
  92. Clumsy Factorial EvaluationDeque · Stack · Arithmetic precedence evaluationMedium
  93. Longest Continuous Subarray With Absolute Diff Within LimitDeque · Deque techniques · Dual monotonic sliding extremaMedium
  94. Jump Game VI (DP with Monotonic Deque)Deque · Deque techniques · Sliding maximum DP / Jump Game VIMedium
  95. Minimum Obstacle Removal to Reach Corner (0-1 BFS)Deque · Deque techniques · Obstacle-entry 0-1 BFSMedium
  96. Sum of Subarray Minimums (Monotonic Stack)Deque · Stack · Subarray contributions / tie spansMedium
  97. Sum of Subarray RangesDeque · Stack · Sum of max/min contributionsMedium
  98. Continuous SubarraysDeque · Deque techniques · Count bounded-range windowsMedium
  99. Basic Calculator IIDeque · Stack · Expression precedenceMedium
  100. 0-1 BFS Shortest Path on GraphDeque · Deque techniques · Graph 0-1 BFSMedium
  101. Predict the Winner in Array GameDeque · Related algorithms · Endpoint minimax interval DPMedium
  102. Text Editor Cursor Simulation via Two DequesDeque · Deque techniques · Cursor editing / two dequesMedium
  103. Shortest Subarray to be Removed to Make Array SortedDeque · Related algorithms · Sorted-prefix/suffix mergingMedium
  104. Car Fleet FormationDeque · Related algorithms · Sorted arrival-time greedyMedium
  105. 132 Pattern DetectionDeque · Stack · 132 pattern invariantMedium
  106. Minimum Cost Tree From Leaf ValuesDeque · Stack · Min-cost leaf tree / greedy stack or DPMedium
  107. Find the Most Competitive SubsequenceDeque · Stack · Competitive subsequence greedyMedium
  108. Smallest Subsequence of Distinct CharactersDeque · Stack · Distinct-character subsequence (duplicate)Medium
  109. Longest Absolute File PathDeque · Stack · Path-depth parsingMedium
  110. Minimum Number of Flips to Make Binary String AlternatingDeque · Queue applications · Rotation + alternating-pattern windowMedium
  111. Verify Preorder Serialization of a Binary TreeDeque · Related algorithms · Serialization slot counter / reductionMedium
  112. Minimum Edge Reversals to Reach DestinationDeque · Deque techniques · Reverse-edge 0-1 BFSMedium
  113. Maximum Width RampDeque · Stack · Candidate-prefix maximum widthMedium
  114. Maximum Sum Circular SubarrayDeque · Deque techniques · Circular bounded-length prefix minimaMedium
  115. Decode StringDeque · Stack · Nested string parser (duplicate)Medium
  116. Maximum Subarray Sum of Length at Most KDeque · Deque techniques · Bounded-length prefix minimumMedium
  117. Count Subarrays With Fixed BoundsDeque · Related algorithms · Last-valid-bound positionsMedium
  118. Subarrays with Exactly K Distinct ElementsDeque · Queue applications · At-most distinct window countingMedium
  119. Cartesian Tree Construction in O(N) via Monotonic StackDeque · Stack · Cartesian tree / monotonic spine stackMedium
  120. Subarray Bitwise OR Monotonic CompressionDeque · Related algorithms · Compressed subarray OR statesMedium
  121. Shortest Substring Within K Edits of a Pattern AnagramDeque · Queue applications · Frequency window with capped multiset matchesMedium
  122. Subarray GCD Monotonic ChainDeque · Related algorithms · Compressed subarray GCD statesMedium
  123. Double-Ended Multi-Stone Score GameDeque · Related algorithms · Bounded-choice interval game DPMedium
  124. Minimum Cost to Make at Least One Valid Path in a Grid (0-1 BFS)Deque · Deque techniques · Directional-grid 0-1 BFSHard
  125. Maximum of Minimums for Every Window SizeDeque · Stack · All-window min spans / propagationHard
  126. Maximum Score of a Good SubarrayDeque · Stack · Minimum-times-length with anchorHard
  127. Constrained Subsequence SumDeque · Deque techniques · Restartable sliding maximum DPHard
  128. Number of Visible People in a QueueDeque · Stack · Visibility / decreasing stackHard
  129. Steps to Make Array Non-DecreasingDeque · Stack · Simultaneous-deletion roundsHard
  130. Trapping Rain Water via Monotonic StackDeque · Stack · Rainwater / stack or two pointersHard
  131. Largest Rectangle in HistogramDeque · Stack · Histogram nearest-smaller spansHard
  132. Maximal Rectangle in 2D Binary MatrixDeque · Stack · Row histograms / maximal rectangleHard
  133. Maximum Frequency Stack via Frequency StacksDeque · Stack · Frequency buckets / recency stackHard
  134. Subarray With Elements Greater Than Varying ThresholdDeque · Stack · Nearest-smaller span thresholdHard
  135. Assign Tasks to Workers with Strength PillsDeque · Deque techniques · Binary search + pill-assignment greedy dequeHard
  136. Shortest Subarray with Sum at Least KDeque · Deque techniques · Negative-prefix shortest subarrayHard
  137. Maximum Points in Angular Vision FieldDeque · Queue applications · Polar angles / circular sorted windowHard
  138. Count Shortest Transformation Sequences in Word GraphDeque · Queue applications · Shortest word-graph path countingHard
  139. Delivering Boxes from Storage to PortsDeque · Deque techniques · Capacity window + transformed DPHard
  140. Sliding Window MedianDeque · Related algorithms · Sliding median / ordered multisetsHard
  141. Max Value of EquationDeque · Deque techniques · Equation rearrangement + window maximumHard
  142. Shortest Path to Collect All KeysDeque · Queue applications · Key-mask state-space BFSHard
  143. Maximum Building HeightDeque · Related algorithms · Restriction propagation / interval peaksHard
  144. Substring with Concatenation of All WordsDeque · Queue applications · Equal-word-length frequency windowsHard
  145. Minimum Window SubsequenceDeque · Related algorithms · Subsequence matching windowsHard
  146. Minimum Visited Cells in a GridDeque · Related algorithms · Forward grid jumps / efficient reachabilityHard
  147. Maximum Balanced Subsequence SumDeque · Related algorithms · Transformed DP + Fenwick/segment treeHard
  148. Smallest Range Covering Elements from K ListsDeque · Queue applications · Merged K-list covering windowHard
  149. Minimum Bus Transfers to Reach DestinationDeque · Queue applications · Route-stop BFSHard
  150. Number of Atoms in Nested Chemical FormulaDeque · Stack · Nested chemical grammar / mapsHard
  151. Minimum Replacements to Make Array ContinuousDeque · Queue applications · Unique sorted range windowHard
  152. Swim in Rising WaterDeque · Queue applications · Minimax elevation pathHard
  153. Shortest Path Visiting All NodesDeque · Queue applications · Multi-source visited-mask BFSHard
  154. Dinic's Algorithm Level Graph via Deque BFSDeque · Queue applications · Dinic flow / residual BFS + blocking DFSHard
  155. Maximum Sum of Three Non-Overlapping SubarraysDeque · Related algorithms · Three-window prefix/suffix DPHard
  156. Number of Submatrices That Sum to TargetDeque · Related algorithms · 2D compression + prefix frequencyHard
  157. Freedom Trail Dial NavigationDeque · Related algorithms · Circular dial DPHard
  158. Convex Hull Trick via Monotonic DequeDeque · Deque techniques · Monotonic convex hull DPHard
  159. Bounded Knapsack in O(NW) via Modulo DequesDeque · Deque techniques · Residue-class bounded knapsack windowsHard
  160. 0-1 BFS in Maze with Phase-Inverting Wind and PortalsDeque · Deque techniques · Two-phase portal 0-1 state BFSHard
  161. Maximum Subarray XOR of Length at Most KDeque · Related algorithms · Sliding XOR binary trieHard
  162. Longest Duplicate SubstringDeque · Related algorithms · Duplicate substrings / suffix or hash searchHard
  163. Smaller Numbers to the RightDeque · Related algorithms · Merge inversion / count-smallerHard
  164. 0-1 BFS for Sokoban Box Push RoutingDeque · Deque techniques · Box/player reachability state BFSHard
  165. 2D Subgrid Absolute Difference Limit via Dual DequesDeque · Deque techniques · Row-pair compression + dual dequesHard
  166. Poet's Problem (1D/1D DP via Monotonic Deque)Deque · Deque techniques · Monotone decision-interval DPVery hard
  167. Highest-Label-First Push-Relabel Max Flow via Deque BucketsDeque · Queue applications · Highest-label push-relabel max flowVery hard
  168. Slope Trick: Minimum Cost to Make Sequence Non-DecreasingDeque · Related algorithms · L1 isotonic regression / slope trick heapVery hard
  169. Tree Depth Profile Merging via Deque Long-Path ShiftDeque · Deque techniques · Long-path tree depth-profile mergingVery hard
  170. Alien's Trick (WQS Binary Search) with Monotonic Deque DPDeque · Deque techniques · WQS + monotonic hull partition DPVery hard
  171. Persistent Sliding Window Maximum with CheckpointsDeque · Queue applications · Persistent range maximum with FIFO state checkpointsVery hard
  172. Circular Fuel Tour with Tank Capacity and Segment AggregationDeque · Queue applications · Capacity-aware associative segment summariesVery hard