KatInterview

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

Stacks & Queues Interview Problems

Practice 5971 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.

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 61–90 of 93 results

  • Stacks & QueuesEasyAuto-graded
    Validate Nested Chemical Formula Brackets

    Tests bracket matching with domain-specific pairing rules where round, square, and curly brackets each have distinct valid nesting constraints.

    Stacks & Queuesstacksbracket matchingsimulationstrings
  • Stacks & QueuesMediumAuto-graded
    Compute Arithmetic Expression with Operator Precedence

    Tests parsing and evaluating mathematical expressions with proper operator precedence and parentheses using stack-based techniques.

    Stacks & Queuesstacksexpression-parsingoperator-precedence
  • Stacks & QueuesMediumAuto-graded
    Concert Venue Ticketing with Capacity and a Waiting Line

    Tests event-driven simulation skills: tracking visitor state, enforcing a seating capacity, managing a FIFO waitlist, and collecting one-time entry fees.

    Stacks & Queuessimulationqueuehash-set
  • Stacks & QueuesHardAuto-graded
    Peak Tower Configuration with Height Limits

    Construct a sequence that rises then falls while respecting per-element caps, maximizing the sum using greedy peak selection and monotonic stacks.

    Stacks & Queuesmonotonic-stackgreedyprefix-sum
  • Stacks & QueuesMediumAuto-graded
    Lexicographically Smallest Digit Sequence from Rise/Fall Pattern

    Tests greedy thinking and stack-based reversal to build the smallest digit string satisfying a sequence of increase and decrease constraints.

    Stacks & Queuesgreedystackstrings
  • Stacks & QueuesMediumAuto-graded
    Compute an Arithmetic Expression Honoring Operator Precedence

    Tests ability to parse and compute integer arithmetic respecting operator precedence without using eval or a full expression parser.

    Stacks & Queuesparsingoperator-precedencestack
  • Stacks & QueuesMediumAuto-graded
    Evaluate Nested Arithmetic Brackets with Sign Propagation

    Tests expression evaluation using a monotonic/simulation stack to handle deeply nested signed bracket expressions with +/- operators and integer literals.

    Stacks & Queuesstacksexpression evaluationparsingsimulation
  • Stacks & QueuesMediumAuto-graded
    Evaluate Arithmetic Expression with Operator Precedence

    Tests implementation of expression evaluation using stacks to handle operator precedence and parentheses correctly.

    Stacks & Queuesstackexpression-parsingoperator-precedence
  • Stacks & QueuesMediumAuto-graded
    Compute Arithmetic Expression with Operator Precedence

    Tests ability to parse and evaluate arithmetic expressions respecting operator precedence and left-to-right associativity without built-in eval.

    Stacks & Queuesparsingoperator-precedencemathstring-processing
  • Stacks & QueuesMediumAuto-graded
    Days Until Higher Temperature

    Tests efficient computation of the distance to the next strictly greater element using a monotonic stack to achieve linear time complexity.

    Stacks & Queuesmonotonic-stacknext-greater-elementarrays
  • Stacks & QueuesMediumAuto-graded
    Collapse Matching Neighbors

    Tests stack-based simulation to eliminate adjacent equal characters iteratively until no more cancellations are possible.

    Stacks & Queuesstackstring-manipulationsimulation
  • Stacks & QueuesHardAuto-graded
    Check Balanced Brackets and Find Tree Level Width

    Tests stack-based matching for nested brackets and BFS position tracking to compute maximum horizontal distance in a binary tree.

    Stacks & Queuesstackbfstree-traversalstring-validation
  • 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