KatInterview

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

Stacks & Queues Interview Problems

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

5969
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 61–90 of 112 results

  • Stacks & QueuesEasyAuto-graded
    Nested Delimiter Checker for Config Expressions

    Checks whether a string of mixed parentheses, braces, and square brackets is properly nested, testing stack-based matching and early rejection in linear time.

    Stacks & Queuesstackparsingstringmatching
  • Stacks & QueuesMediumModel answer
    Group Deletion Stack and Boundary Path Collection

    Remove consecutive identical-character groups from a string and collect a binary tree's boundary nodes in a specific mirror order.

    Stacks & Queuesstackbinary-treestring-manipulationrun-length-encoding
  • Stacks & QueuesMediumModel answer
    Compute Per-Function Runtimes from a Profiler Event Log

    Parse a time-ordered sequence of START/END events, compute inclusive and exclusive runtimes per function, and identify the most expensive function by self-time.

    Stacks & Queuesstacksimulationprofilingcall-stack
  • Stacks & QueuesHardAuto-graded
    Reconstruct Function Lifetimes from Periodic Stack Snapshots

    Tests ability to diff consecutive call-stack snapshots using longest-common-prefix analysis and stack unwinding to produce ordered START/END lifecycle events.

    Stacks & Queuesstacksimulationtwo-pointers
  • Stacks & QueuesHardAuto-graded
    Peak Values in Fixed-Length Subarrays

    Tests understanding of monotonic deques to efficiently track the largest element across consecutive fixed-size subarrays in linear time.

    Stacks & Queuesdequesliding-windowmonotonic-queue
  • Stacks & QueuesMediumModel answer
    Maximize Throughput in a Serial Manufacturing Pipeline

    Design and simulate a fixed-time serial pipeline to maximize completed units, given per-stage processing times, inter-stage buffer capacities, and blocking-after-service rules.

    Stacks & Queuessimulationschedulingqueuesthroughput
  • Stacks & QueuesEasyAuto-graded
    Balanced Delimiter Validation with a Stack

    Decide whether a bracket-only string is properly nested and matched, using a LIFO stack of pending openers.

    Stacks & Queuesstackstringsparsing
  • Stacks & QueuesHardAuto-graded
    Simulate a FIFO Queue with Two Stacks

    Tests whether you can emulate first-in-first-out ordering using only two LIFO stacks and explain the amortized cost of each operation.

    Stacks & Queuesstacksqueueamortized-analysis
  • Stacks & QueuesMediumAuto-graded
    Single-Threaded CPU: Exclusive Runtimes and Stack Snapshot

    Tests stack simulation and interval reasoning by computing per-function exclusive execution time and reconstructing the active call stack at a query timestamp from a sorted event log.

    Stacks & Queuesstacksimulationinterval-reasoning
  • Stacks & QueuesHardModel answer
    Build a Type-Safe C++ Stack from Raw Storage

    Implement a generic, dynamically growing C++ stack using raw memory and placement new, then defend every lifetime, allocation, and call-semantics decision.

    Stacks & QueuesC++memory-managementtemplatesobject-lifetime
  • Stacks & QueuesMediumAuto-graded
    Bracket Nesting Check and Rotating Cipher

    Tests stack-based bracket validation and modular arithmetic to rotate lowercase letters circularly across the alphabet.

    Stacks & Queuesstacksstringsmodular-arithmetic
  • Stacks & QueuesMediumAuto-graded
    Calculate Arithmetic Expression with Negation and Grouping

    Tests building an operator-precedence parser using stacks to handle binary operations, unary negation, parentheses, and zero-truncating division.

    Stacks & Queuesstacksparsingoperator-precedencestring-processing
  • Stacks & QueuesMediumAuto-graded
    Cascade Removal of Equal Neighbor Groups

    Tests stack-based simulation of iterative removals that trigger chain reactions when fragments recombine.

    Stacks & Queuesstackstringsimulation
  • Stacks & QueuesMediumAuto-graded
    Skyline Visible Buildings Count

    Tests ability to use a monotonic stack to count, for each building, how many previous buildings are visible looking back from it along a city skyline.

    Stacks & Queuesmonotonic stackarrayssimulation
  • Stacks & QueuesMediumAuto-graded
    Bracket Matching, Interval Union, and Expression Parsing

    Tests stack-based bracket validation, interval merging with endpoint semantics, and arithmetic evaluation with unary operators.

    Stacks & Queuesstacksintervalsparsingexpression-evaluation
  • Stacks & QueuesMediumAuto-graded
    Trim a Bracket String to Its Longest Balanced Form

    Tests stack-based bracket matching: find and remove the fewest characters from a parentheses-only string to leave a fully balanced result.

    Stacks & Queuesstacksstringsgreedy
  • Stacks & QueuesMediumAuto-graded
    Identify Invalid Parentheses for Removal

    Tests stack-based matching to find the minimum set of parenthesis indices that must be removed to balance a string.

    Stacks & Queuesstackstring-processinggreedy
  • 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 & QueuesMediumModel answer
    Stack Trace Event Stream from Periodic Samples

    Convert a sequence of call stack snapshots into function entry and exit events with configurable debouncing to filter transient frames.

    Stacks & Queuesstacksarrayssimulationstate-machine
  • 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