KatInterview

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

Stacks & Queues Interview Problems

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

5965
Problems
2208
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 112 results

  • Stacks & QueuesEasyAuto-graded
    Typed Value Stack Interpreter with Mixed Addition

    Simulate a stack machine whose values are tagged ints or strings, where ADD sums two ints or concatenates otherwise, and return the printed lines.

    Stacks & Queuesstacksimulationstringstagged-union
  • Stacks & QueuesMediumAuto-graded
    Fixed-Width Window Folds with Add, Multiply, or AND

    Compute the fold of every length-k window of an array under a named associative operation, ideally in linear time without relying on inverse operations.

    Stacks & Queuessliding-windowtwo-stacksassociative-operationqueue
  • Stacks & QueuesMediumModel answer
    Line of Sight Counts for Each Person in a Row

    For each person in a row, count how many people further right they can see when anyone standing between must be shorter than both of them. Needs an O(n) approach.

    Stacks & Queuesmonotonic-stackarraysamortized-analysisnext-greater-element
  • Stacks & QueuesMediumModel answer
    Java Concurrent Collections Deep Dive: ConcurrentHashMap and Queues

    Explore the internal architecture, thread-safety mechanisms, and practical performance trade-offs of Java's ConcurrentHashMap and concurrent queue variants.

    Stacks & Queuesjavaconcurrencydata-structuresmultithreading
  • Stacks & QueuesMediumAuto-graded
    Collapse Adjacent Edits Before Applying Them to a Text Buffer

    Simulate a queue of insert and format edits, merging adjacent inserts and dropping repeated adjacent formats, then return the final text and ordered list of applied styles.

    Stacks & Queuesstacksimulationcommand-patternstrings
  • Stacks & QueuesMediumAuto-graded
    Normalize a Filesystem Location String

    Reduce an absolute Unix-style path to its canonical form by resolving repeated slashes, current-directory and parent-directory segments, using a stack.

    Stacks & Queuesstackstring-parsingsimulationpaths
  • Stacks & QueuesEasyAuto-graded
    Leftover Brackets After Pairing Up a Parenthesis String

    Count the parentheses left over after forming the maximum number of valid "(" before ")" pairs, testing a greedy counter scan or stack over a string.

    Stacks & Queuesstackgreedystringsparentheses
  • Stacks & QueuesMediumAuto-graded
    Infer Execution Events from Call Stack Snapshots

    Reconstruct chronological function START and END lifecycle events by evaluating structural differences across consecutive call stack snapshots.

    Stacks & Queuesstacks-queuesarraysstrings
  • Stacks & QueuesMediumAuto-graded
    Four-Function Calculator Without Parentheses

    Evaluate a string of non-negative integers with +, -, *, / and spaces, honoring precedence and truncating division toward zero, without using eval.

    Stacks & Queuesstring-parsingstackoperator-precedencesimulation
  • Stacks & QueuesMediumModel answer
    Build a Calculator with Variables, Unary Signs and Parentheses

    Write a linear-time evaluator for integer expressions with variables, precedence, unary signs, parentheses, truncating division and 64-bit error handling.

    Stacks & Queuesparsingrecursive-descentexpression-evaluationtokenization
  • Stacks & QueuesMediumAuto-graded
    Expand a Compressed Bracket Pattern String

    Tests stack-based parsing of nested repeat-count patterns, including multi-digit counts, nesting, and trailing letters, to rebuild the fully expanded string.

    Stacks & Queuesstackstringparsingnested-structures
  • Stacks & QueuesMediumAuto-graded
    Expand a Compact Pattern with Nested Multipliers

    Expand a string in which a positive integer followed by a bracketed block means that block repeats, with nesting; tests stack or recursive parsing and multi-digit number handling.

    Stacks & Queuesstackstring-parsingnested-structuresrecursion
  • Stacks & QueuesMediumAuto-graded
    Unwrap Deeply Nested Lists Into One Sequence

    Collect every integer from a structure of arbitrarily deep nested lists in left-to-right order, without recursion, so extremely deep inputs do not overflow the call stack.

    Stacks & Queuesstackdfsiteratorsnested-lists
  • Stacks & QueuesEasyAuto-graded
    Balanced Delimiters Checker

    Decide whether a string made only of round, square and curly brackets is correctly paired and nested, which tests stack-based matching and edge-case handling.

    Stacks & Queuesstackstringsparsing
  • Stacks & QueuesEasyAuto-graded
    Check Block Nesting in a Flat Marker Sequence

    Scan a list of tokens and decide whether every OPEN-style marker is matched by a later close marker, using a running counter and early rejection.

    Stacks & Queuescounterbalanced-bracketssingle-passstrings
  • Stacks & QueuesMediumAuto-graded
    Wait Time Until a Strictly Larger Sensor Value

    Find, for each position in a sequence, the distance to the next strictly larger element, using a monotonic stack to achieve linear time.

    Stacks & Queuesmonotonic-stackarraysnext-greater-element
  • Stacks & QueuesMediumAuto-graded
    Smallest Subsequence Containing Each Letter Once

    Build the lexicographically smallest subsequence that uses every distinct letter of a string exactly once, using a greedy monotonic stack with remaining-count tracking.

    Stacks & Queuesmonotonic-stackgreedystringssubsequence
  • Stacks & QueuesMediumAuto-graded
    Evaluate a Spaced Arithmetic String Without Parentheses

    Evaluate an integer expression with +, -, *, / using standard precedence and truncating division, in a single pass over a string with arbitrary spacing.

    Stacks & Queuesparsingstringstackoperator-precedence
  • Stacks & QueuesMediumModel answer
    Build a Tiny Expression Language Interpreter in Three Stages

    Implement a lexer, recursive-descent parser and evaluator for a small integer language with variables, unary minus, precedence, truncating division and print.

    Stacks & Queuesparsinginterpreterrecursive-descentast
  • Stacks & QueuesMediumAuto-graded
    Parenthesized Integer Calculator with Unary Negation

    Evaluate an integer expression with +, -, *, /, parentheses and unary minus in one iterative pass, using precedence rules and division that truncates toward zero.

    Stacks & Queuesstackparsingexpression-evaluationshunting-yard
  • Stacks & QueuesMediumModel answer
    Arithmetic String Calculator with Operator Precedence

    Compute the integer result of a string holding non-negative numbers, four operators and spaces, honoring precedence and truncating division, without eval and with linear time.

    Stacks & Queuesparsingstackstringoperator-precedence
  • Stacks & QueuesMediumAuto-graded
    Expand Nested Repeat Notation into a Full String

    Expand a string containing nested count[text] repeat groups into its full form, using a stack or recursion to parse multi-digit counts and nesting correctly.

    Stacks & Queuesstackstring-parsingnested-structuresrecursion
  • Stacks & QueuesMediumAuto-graded
    Deserialize Nested List Structure

    Parse a string encoding nested lists and non-negative integers into a Python list structure.

    Stacks & Queuesstacksstringsparsingrecursion
  • Stacks & QueuesMediumAuto-graded
    Strip Unmatched Brackets From a Text Line

    Delete exactly the brackets that cannot be paired so the remaining text is well-formed, using a single linear scan with a stack or counters.

    Stacks & Queuesstackstringparenthesesgreedy
  • Stacks & QueuesEasyAuto-graded
    Right-Side Larger Neighbor Lookup for Selected Values

    Tests whether you can precompute the nearest strictly larger value to the right for every element using a monotonic stack, then answer lookups for a chosen list of values.

    Stacks & Queuesmonotonic-stackhash-maparrays
  • Stacks & QueuesMediumAuto-graded
    Expand Nested Repeat Patterns in an Encoded String

    Tests stack-based parsing of nested, multi-digit repeat patterns of the form count[text] to rebuild the fully expanded string.

    Stacks & Queuesstackstring-parsingnested-structuredecoding
  • Stacks & QueuesMediumAuto-graded
    Longest Stretch With Bounded Spread

    Find the longest contiguous stretch of an integer list whose largest and smallest values differ by at most a tolerance, using a sliding window with monotonic deques.

    Stacks & Queuessliding-windowmonotonic-dequearraystwo-pointers
  • Stacks & QueuesMediumAuto-graded
    Resolve Field Paths in a Nested Message Schema

    Parse brace-delimited nested message definitions line by line, then check which dotted query paths name an actual field, tracking scope with a stack.

    Stacks & Queuesparsingstackhash-setstrings
  • Stacks & QueuesEasyAuto-graded
    Check Whether Bracket Pairs Are Correctly Nested

    Decide whether a string of round, square and curly brackets is well formed, which tests the use of a stack for last-in-first-out matching.

    Stacks & Queuesstackstringsparsing
  • Stacks & QueuesMediumModel answer
    Troubleshooting Silent Execution in Python Async Workflows

    Analyze and fix a Python async script that finishes silently without invoking its async functions, and explore concurrent execution options with asyncio.

    Stacks & Queuespythonasyncioconcurrencydebugging