KatInterview

practice a little every day — you've got this ♡

Stacks & Queues Interview Problems

Practice 5967 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

5967
Problems
2210
Auto-graded
15
Topics
272
Added today

Showing 91–112 of 112 results

  • Stacks & QueuesMediumModel answer
    Parse and Compute Arithmetic Expression with Recursion

    Write a parser that evaluates arithmetic expressions with integers, four operators, parentheses, and unary negation using recursive descent or explicit stack DFS.

    Stacks & Queuesrecursionparsingoperatorsdfs
  • Stacks & QueuesHardAuto-graded
    Final Sale Prices with Discount Tracking

    Tests monotonic stack usage to efficiently find next smaller-or-equal elements and aggregate results with index tracking.

    Stacks & Queuesmonotonic-stackarraysaggregation
  • Stacks & QueuesHardAuto-graded
    Validate Nested Chemical Formula Expressions

    Tests deep bracket-matching with multiplicative expansion rules by validating and evaluating a chemical-formula-style string with nested parentheses and numeric multipliers.

    Stacks & Queuesstacksbracket matchingparsingsimulation
  • Stacks & QueuesEasyAuto-graded
    Validate Nested Tag Pairs in a Markup String

    Tests whether candidates can simulate bracket-matching logic with named tags, enforcing strict open/close pairing and proper nesting order.

    Stacks & Queuesstacksbracket matchingparsingsimulation
  • Stacks & QueuesHardAuto-graded
    Evaluate a Ternary-Chained Arithmetic Expression

    Tests expression evaluation using a monotonic/operator-precedence stack to correctly parse and compute a string containing +, -, *, /, parentheses, and nested ternary operators.

    Stacks & Queuesstacksexpression evaluationparsingmonotonic stack
  • Stacks & QueuesMediumAuto-graded
    Reconstruct Call Events from Profiler Snapshots

    Tests stack trace interpretation, event inference from sparse data, and algorithmic reasoning about nesting and correctness.

    Stacks & Queuesstacksalgorithmsdata-structures
  • Stacks & QueuesMediumAuto-graded
    Minimum Length Subarray with Sum Threshold

    Tests the ability to optimize subarray sum queries using prefix sums and monotonic deque when values can be negative.

    Stacks & Queuesprefix-sumsmonotonic-dequesliding-windowarray
  • Stacks & QueuesEasyAuto-graded
    Evaluate Simple Arithmetic String Expressions

    Tests ability to evaluate a string expression containing non-negative integers, +, -, *, / operators, and parentheses using a stack-based approach.

    Stacks & Queuesstacksexpression evaluationparsing
  • Stacks & QueuesEasyAuto-graded
    Next Warmer Day in a Temperature Log

    Tests the ability to use a monotonic stack to efficiently find, for each day, how many days until a strictly warmer temperature is recorded.

    Stacks & Queuesstackmonotonic stackarray
  • Stacks & QueuesEasyAuto-graded
    Print Queue Page Order Simulator

    Tests queue simulation by modeling a shared printer that interleaves multi-page jobs across rounds, returning the final page-output order.

    Stacks & Queuesqueuesimulationarrays
  • Stacks & QueuesHardAuto-graded
    Reconstruct Function Entry/Exit Events from Call Stack Snapshots

    Tests ability to compute positional diffs between consecutive call stack snapshots and emit correctly ordered START/END events using a stack-based mental model.

    Stacks & Queuesstacksimulationstring manipulation
  • Stacks & QueuesHardAuto-graded
    Simulate a Multi-Lane Toll Plaza Queue

    Tests queue simulation skills by modeling vehicles routing through toll lanes with dynamic overflow and lane-closing logic.

    Stacks & Queuesqueuesimulationgreedy
  • Stacks & QueuesHardAuto-graded
    Validate Nested Tag Expressions with Typed Bracket Rules

    Tests bracket matching using a stack to enforce context-sensitive nesting rules across four distinct bracket types with extra validity constraints.

    Stacks & Queuesstacksbracket matchingparsingsimulation
  • Stacks & QueuesHardAuto-graded
    Largest Rectangle Under a Skyline with Forbidden Zones

    Tests the ability to apply a monotonic stack to find the largest rectangular area under a histogram while skipping columns that are marked as forbidden.

    Stacks & Queuesmonotonic stackarraysgeometry
  • Stacks & QueuesMediumAuto-graded
    Validate Nested Markup Tag Sequence

    Tests bracket matching logic by verifying that a simplified markup string with typed opening/closing tags is correctly nested and properly closed.

    Stacks & Queuesstackparsingsimulation
  • Stacks & QueuesMediumAuto-graded
    Validate Nested Scope Tags with Typed Bracket Pairs

    Tests bracket matching by parsing a string of typed scope-open/close tokens and verifying correct nesting, ordering, and balance according to a precedence table.

    Stacks & Queuesstacksbracket matchingparsingsimulation
  • Stacks & QueuesEasyAuto-graded
    Find the Nearest Taller Building to the Left

    Tests the ability to use a monotonic stack to efficiently find, for each building in a skyline, the index of the nearest building to its left that is strictly taller.

    Stacks & Queuesmonotonic stackarraysstack
  • Stacks & QueuesHardAuto-graded
    Maximum Visible Buildings on a Skyline Strip

    Tests ability to use a monotonic stack to compute, for each building, how many previous buildings it "blocks" and find the building that maximally reduces the visible skyline count.

    Stacks & Queuesmonotonic stackarrayssimulation
  • Stacks & QueuesEasyAuto-graded
    Evaluate a Simple Postfix (RPN) Arithmetic Expression

    Tests whether a candidate can use a stack to correctly evaluate a postfix arithmetic expression involving integers and the four basic operators.

    Stacks & Queuesstacksexpression evaluationsimulation
  • Stacks & QueuesMediumAuto-graded
    Simulate a Printer Queue with Priority Levels

    Tests queue simulation by processing print jobs where higher-priority jobs preempt lower-priority ones, requiring candidates to track position and reorder the queue correctly.

    Stacks & Queuesqueuesimulationgreedy
  • Stacks & QueuesHardAuto-graded
    Validate Nested Expressions with Typed Bracket Scopes

    Tests bracket matching with complex rules: typed pairs, mandatory ordered sub-structure inside scopes, and precedence-aware nesting constraints.

    Stacks & Queuesstacksbracket matchingparsingsimulation
  • Stacks & QueuesEasyAuto-graded
    Simulate a Cafeteria Serving Queue

    Tests the ability to simulate a round-robin service queue where customers cycle back if unserved, tracking when each customer is finally served.

    Stacks & Queuesqueuesimulationdata structures