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
- Open a question in the editor and read the statement, inputs, and expected output. Predict the result for a small example before writing code.
- Write a solution and run the examples. If a result differs from your prediction, reduce the input until you can follow each step.
- 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 totalOpen a question in the editor to read its statement and examples. Sign in to practice.
- Deque Four Core Operations SequenceDeque · Deque techniques · Deque operations and sequence drillsBasic
- Peek Front and Peek BackDeque · Deque techniques · Deque operations and sequence drillsBasic
- Deque Underflow DetectionDeque · Deque techniques · Deque operations and sequence drillsBasic
- Deque Size and Emptiness StatusDeque · Deque techniques · Deque operations and sequence drillsBasic
- Circular Array Deque Pointer WraparoundDeque · Deque techniques · Deque operations and sequence drillsBasic
- Bounded Deque Overflow and UnderflowDeque · Deque techniques · Deque operations and sequence drillsBasic
- Palindrome Verification via DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
- Sequence Inversion via Front EnqueueDeque · Deque techniques · Deque operations and sequence drillsBasic
- Deque Rotation by One Position (Left and Right)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Deque Element Statistics: Sum, Min, and MaxDeque · Queue applications · Deque operations and sequence drillsBasic
- Check if Two Deques are IdenticalDeque · Queue applications · Deque operations and sequence drillsBasic
- Deque Multi-Step Rotation by K PositionsDeque · Deque techniques · Deque operations and sequence drillsBasic
- Swap Front and Back ElementsDeque · Deque techniques · Deque operations and sequence drillsBasic
- Alternating Ends Insertion (Zigzag Push)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Alternating Ends Extraction (Zigzag Pop)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Count Target Occurrences in DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Distance from Front and Distance from BackDeque · Queue applications · Deque operations and sequence drillsBasic
- Delete All Occurrences of Target from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Duplicate Deque (Preserve Front and Back Order)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Concatenate Two Deques (Append to Back)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Prepend One Deque to Another (Prepend to Front)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Check if Deque Elements are SortedDeque · Queue applications · Deque operations and sequence drillsBasic
- Reverse the First K Elements of a DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
- Reverse the Last K Elements of a DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
- Doubly Linked List Deque Traversal (Forward and Backward)Deque · Deque techniques · Deque operations and sequence drillsBasic
- Count Unique Elements in DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Split Deque into Two HalvesDeque · Deque techniques · Deque operations and sequence drillsBasic
- Interleave First Half and Second HalfDeque · Deque techniques · Deque operations and sequence drillsBasic
- Partition Evens to Front and Odds to BackDeque · Deque techniques · Deque operations and sequence drillsBasic
- Partition Negatives to Front and Positives to BackDeque · Deque techniques · Deque operations and sequence drillsBasic
- Middle Element(s) of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Delete Middle Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Remove Every Second Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Outside-In Pair SumsDeque · Deque techniques · Deque operations and sequence drillsBasic
- Stack Using Deque OperationsDeque · Stack · Deque operations and sequence drillsBasic
- Queue Using Deque OperationsDeque · Deque techniques · Deque operations and sequence drillsBasic
- Reverse First K and Last K Elements of DequeDeque · Deque techniques · Deque operations and sequence drillsBasic
- Filter Multiples of K from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Delete Minimum Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Delete Maximum Element from DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Train Shunting Yard SimulationDeque · Deque techniques · Deque operations and sequence drillsBasic
- Check for Alternating SignsDeque · Queue applications · Deque operations and sequence drillsBasic
- Sort Deque Elements in Non-Decreasing OrderDeque · Queue applications · Deque operations and sequence drillsBasic
- Move All Zeros to the Back of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Move All Zeros to the Front of DequeDeque · Queue applications · Deque operations and sequence drillsBasic
- Circular Array Deque Physical Slots and PointersDeque · Deque techniques · Deque operations and sequence drillsBasic
- Complete Double-Ended Queue Operations HarnessDeque · Deque techniques · Complete deque operation harnessBasic
- Valid Palindrome After at Most One DeletionDeque · Queue applications · Palindrome with one deletion / two pointersEasy
- Remove All Adjacent Duplicates Using a DequeDeque · Stack · Adjacent-pair string reductionEasy
- Backspace String CompareDeque · Stack · Backspace simulationEasy
- First Negative Integer in Every Window of Size KDeque · Deque techniques · Window candidate queueEasy
- Card Discard and Cycle GameDeque · Deque techniques · Discard/rotate simulationEasy
- Baseball Game Score TrackingDeque · Stack · Score record simulationEasy
- Make The String Great (Adjacent Case Elimination)Deque · Stack · Case-pair reductionEasy
- Parity Interleaving via DequesDeque · Deque techniques · Stable parity interleavingEasy
- Maximum Sum in a Sliding Window of Size KDeque · Queue applications · Fixed-window running sumEasy
- Minimum String Length After Removing Target SubstringsDeque · Stack · Target-pair reductionEasy
- Crawler Log Folder DepthDeque · Related algorithms · Directory depth counterEasy
- First Unique Character in Stream via Candidate DequeDeque · Deque techniques · Streaming uniqueness / FIFO candidatesEasy
- Final Prices With a Special Discount (Monotonic Stack)Deque · Stack · Next smaller-or-equal discountEasy
- Next Greater Element I (Monotonic Stack)Deque · Stack · Next greater elementEasy
- Maximum Nesting Depth of ParenthesesDeque · Related algorithms · Depth counterEasy
- Winner of Circular Game via Deque ShiftsDeque · Deque techniques · Josephus simulationEasy
- Student Cafeteria Queue Simulation via DequeDeque · Queue applications · Queue rotation / preference countsEasy
- Moving Average from Data Stream via DequeDeque · Deque techniques · Moving average / running sumEasy
- Ticket Counter Purchase Time via Deque SimulationDeque · Deque techniques · Ticket round-robin simulationEasy
- Reverse Vowels of a StringDeque · Related algorithms · Vowel reversal / two pointersEasy
- Lemonade ChangeDeque · Related algorithms · Greedy bill countersEasy
- Poison Duration Interval TrackingDeque · Related algorithms · Interval union in sorted orderEasy
- Design Circular DequeDeque · Deque techniques · Circular deque designMedium
- Binary Tree Zigzag Level Order Traversal via DequeDeque · Queue applications · Tree zigzag level traversalMedium
- Design Front-Middle-Back Queue via Two DequesDeque · Deque techniques · Balanced middle queueMedium
- Reveal Cards in Increasing Order via DequeDeque · Deque techniques · Reverse reveal simulationMedium
- Sliding Window Minimum via Monotonic DequeDeque · Deque techniques · Monotonic sliding minimumMedium
- Sliding Window Maximum via Monotonic DequeDeque · Deque techniques · Monotonic sliding maximumMedium
- Browser History Navigation via DequeDeque · Queue applications · History cursor / two stacksMedium
- Validate Stack Sequences SimulationDeque · Stack · Stack permutation validationMedium
- Simplify Canonical Unix PathDeque · Stack · Path component normalizationMedium
- Basic 0-1 BFS in a Weighted GridDeque · Deque techniques · 0-1 weighted grid BFSMedium
- Winner of an Array Game with Consecutive RoundsDeque · Deque techniques · Champion simulation with large-K shortcutMedium
- Longest Palindrome from Two-Letter WordsDeque · Related algorithms · Frequency pairing / palindrome constructionMedium
- Evaluate Reverse Polish NotationDeque · Stack · RPN evaluationMedium
- Daily Temperatures Waiting Days (Monotonic Stack)Deque · Stack · Next warmer dayMedium
- Asteroid Collision SimulationDeque · Stack · Collision resolutionMedium
- Online Stock Span (Monotonic Stack)Deque · Stack · Aggregated monotonic spanMedium
- Score of ParenthesesDeque · Stack · Parenthesis scoringMedium
- Remove K Digits to Minimize Value via Monotonic StackDeque · Stack · Greedy digit removalMedium
- Next Greater Element in a Circular Array (Monotonic Stack)Deque · Stack · Circular next greater elementMedium
- Days with Strictly Lower Temperatures via Monotonic StackDeque · Stack · Strict colder-prefix spanMedium
- Dota2 Senate Voting Simulation via Dual DequesDeque · Deque techniques · Two-party scheduling / dual FIFOMedium
- Binary Tree Right Side View via Level DequeDeque · Queue applications · Tree right view BFSMedium
- Clumsy Factorial EvaluationDeque · Stack · Arithmetic precedence evaluationMedium
- Longest Continuous Subarray With Absolute Diff Within LimitDeque · Deque techniques · Dual monotonic sliding extremaMedium
- Jump Game VI (DP with Monotonic Deque)Deque · Deque techniques · Sliding maximum DP / Jump Game VIMedium
- Minimum Obstacle Removal to Reach Corner (0-1 BFS)Deque · Deque techniques · Obstacle-entry 0-1 BFSMedium
- Sum of Subarray Minimums (Monotonic Stack)Deque · Stack · Subarray contributions / tie spansMedium
- Sum of Subarray RangesDeque · Stack · Sum of max/min contributionsMedium
- Continuous SubarraysDeque · Deque techniques · Count bounded-range windowsMedium
- Basic Calculator IIDeque · Stack · Expression precedenceMedium
- 0-1 BFS Shortest Path on GraphDeque · Deque techniques · Graph 0-1 BFSMedium
- Predict the Winner in Array GameDeque · Related algorithms · Endpoint minimax interval DPMedium
- Text Editor Cursor Simulation via Two DequesDeque · Deque techniques · Cursor editing / two dequesMedium
- Shortest Subarray to be Removed to Make Array SortedDeque · Related algorithms · Sorted-prefix/suffix mergingMedium
- Car Fleet FormationDeque · Related algorithms · Sorted arrival-time greedyMedium
- 132 Pattern DetectionDeque · Stack · 132 pattern invariantMedium
- Minimum Cost Tree From Leaf ValuesDeque · Stack · Min-cost leaf tree / greedy stack or DPMedium
- Find the Most Competitive SubsequenceDeque · Stack · Competitive subsequence greedyMedium
- Smallest Subsequence of Distinct CharactersDeque · Stack · Distinct-character subsequence (duplicate)Medium
- Longest Absolute File PathDeque · Stack · Path-depth parsingMedium
- Minimum Number of Flips to Make Binary String AlternatingDeque · Queue applications · Rotation + alternating-pattern windowMedium
- Verify Preorder Serialization of a Binary TreeDeque · Related algorithms · Serialization slot counter / reductionMedium
- Minimum Edge Reversals to Reach DestinationDeque · Deque techniques · Reverse-edge 0-1 BFSMedium
- Maximum Width RampDeque · Stack · Candidate-prefix maximum widthMedium
- Maximum Sum Circular SubarrayDeque · Deque techniques · Circular bounded-length prefix minimaMedium
- Decode StringDeque · Stack · Nested string parser (duplicate)Medium
- Maximum Subarray Sum of Length at Most KDeque · Deque techniques · Bounded-length prefix minimumMedium
- Count Subarrays With Fixed BoundsDeque · Related algorithms · Last-valid-bound positionsMedium
- Subarrays with Exactly K Distinct ElementsDeque · Queue applications · At-most distinct window countingMedium
- Cartesian Tree Construction in O(N) via Monotonic StackDeque · Stack · Cartesian tree / monotonic spine stackMedium
- Subarray Bitwise OR Monotonic CompressionDeque · Related algorithms · Compressed subarray OR statesMedium
- Shortest Substring Within K Edits of a Pattern AnagramDeque · Queue applications · Frequency window with capped multiset matchesMedium
- Subarray GCD Monotonic ChainDeque · Related algorithms · Compressed subarray GCD statesMedium
- Double-Ended Multi-Stone Score GameDeque · Related algorithms · Bounded-choice interval game DPMedium
- Minimum Cost to Make at Least One Valid Path in a Grid (0-1 BFS)Deque · Deque techniques · Directional-grid 0-1 BFSHard
- Maximum of Minimums for Every Window SizeDeque · Stack · All-window min spans / propagationHard
- Maximum Score of a Good SubarrayDeque · Stack · Minimum-times-length with anchorHard
- Constrained Subsequence SumDeque · Deque techniques · Restartable sliding maximum DPHard
- Number of Visible People in a QueueDeque · Stack · Visibility / decreasing stackHard
- Steps to Make Array Non-DecreasingDeque · Stack · Simultaneous-deletion roundsHard
- Trapping Rain Water via Monotonic StackDeque · Stack · Rainwater / stack or two pointersHard
- Largest Rectangle in HistogramDeque · Stack · Histogram nearest-smaller spansHard
- Maximal Rectangle in 2D Binary MatrixDeque · Stack · Row histograms / maximal rectangleHard
- Maximum Frequency Stack via Frequency StacksDeque · Stack · Frequency buckets / recency stackHard
- Subarray With Elements Greater Than Varying ThresholdDeque · Stack · Nearest-smaller span thresholdHard
- Assign Tasks to Workers with Strength PillsDeque · Deque techniques · Binary search + pill-assignment greedy dequeHard
- Shortest Subarray with Sum at Least KDeque · Deque techniques · Negative-prefix shortest subarrayHard
- Maximum Points in Angular Vision FieldDeque · Queue applications · Polar angles / circular sorted windowHard
- Count Shortest Transformation Sequences in Word GraphDeque · Queue applications · Shortest word-graph path countingHard
- Delivering Boxes from Storage to PortsDeque · Deque techniques · Capacity window + transformed DPHard
- Sliding Window MedianDeque · Related algorithms · Sliding median / ordered multisetsHard
- Max Value of EquationDeque · Deque techniques · Equation rearrangement + window maximumHard
- Shortest Path to Collect All KeysDeque · Queue applications · Key-mask state-space BFSHard
- Maximum Building HeightDeque · Related algorithms · Restriction propagation / interval peaksHard
- Substring with Concatenation of All WordsDeque · Queue applications · Equal-word-length frequency windowsHard
- Minimum Window SubsequenceDeque · Related algorithms · Subsequence matching windowsHard
- Minimum Visited Cells in a GridDeque · Related algorithms · Forward grid jumps / efficient reachabilityHard
- Maximum Balanced Subsequence SumDeque · Related algorithms · Transformed DP + Fenwick/segment treeHard
- Smallest Range Covering Elements from K ListsDeque · Queue applications · Merged K-list covering windowHard
- Minimum Bus Transfers to Reach DestinationDeque · Queue applications · Route-stop BFSHard
- Number of Atoms in Nested Chemical FormulaDeque · Stack · Nested chemical grammar / mapsHard
- Minimum Replacements to Make Array ContinuousDeque · Queue applications · Unique sorted range windowHard
- Swim in Rising WaterDeque · Queue applications · Minimax elevation pathHard
- Shortest Path Visiting All NodesDeque · Queue applications · Multi-source visited-mask BFSHard
- Dinic's Algorithm Level Graph via Deque BFSDeque · Queue applications · Dinic flow / residual BFS + blocking DFSHard
- Maximum Sum of Three Non-Overlapping SubarraysDeque · Related algorithms · Three-window prefix/suffix DPHard
- Number of Submatrices That Sum to TargetDeque · Related algorithms · 2D compression + prefix frequencyHard
- Freedom Trail Dial NavigationDeque · Related algorithms · Circular dial DPHard
- Convex Hull Trick via Monotonic DequeDeque · Deque techniques · Monotonic convex hull DPHard
- Bounded Knapsack in O(NW) via Modulo DequesDeque · Deque techniques · Residue-class bounded knapsack windowsHard
- 0-1 BFS in Maze with Phase-Inverting Wind and PortalsDeque · Deque techniques · Two-phase portal 0-1 state BFSHard
- Maximum Subarray XOR of Length at Most KDeque · Related algorithms · Sliding XOR binary trieHard
- Longest Duplicate SubstringDeque · Related algorithms · Duplicate substrings / suffix or hash searchHard
- Smaller Numbers to the RightDeque · Related algorithms · Merge inversion / count-smallerHard
- 0-1 BFS for Sokoban Box Push RoutingDeque · Deque techniques · Box/player reachability state BFSHard
- 2D Subgrid Absolute Difference Limit via Dual DequesDeque · Deque techniques · Row-pair compression + dual dequesHard
- Poet's Problem (1D/1D DP via Monotonic Deque)Deque · Deque techniques · Monotone decision-interval DPVery hard
- Highest-Label-First Push-Relabel Max Flow via Deque BucketsDeque · Queue applications · Highest-label push-relabel max flowVery hard
- Slope Trick: Minimum Cost to Make Sequence Non-DecreasingDeque · Related algorithms · L1 isotonic regression / slope trick heapVery hard
- Tree Depth Profile Merging via Deque Long-Path ShiftDeque · Deque techniques · Long-path tree depth-profile mergingVery hard
- Alien's Trick (WQS Binary Search) with Monotonic Deque DPDeque · Deque techniques · WQS + monotonic hull partition DPVery hard
- Persistent Sliding Window Maximum with CheckpointsDeque · Queue applications · Persistent range maximum with FIFO state checkpointsVery hard
- Circular Fuel Tour with Tank Capacity and Segment AggregationDeque · Queue applications · Capacity-aware associative segment summariesVery hard