Topic
Stacks & Queues interview problems
Monotonic stacks, parsing and simulation. 112 original problems, each with hidden test cases you can run in the browser.
22 easy74 medium16 hard
Showing 1–30 of 112 results
Simulate a stack machine whose values are tagged ints or strings, where ADD sums two ints or concatenates otherwise, and return the printed lines.
Auto-gradedstacksimulationstringstagged-unionCompute the fold of every length-k window of an array under a named associative operation, ideally in linear time without relying on inverse operations.
Auto-gradedsliding-windowtwo-stacksassociative-operationqueueFor 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.
Model answermonotonic-stackarraysamortized-analysisnext-greater-elementExplore the internal architecture, thread-safety mechanisms, and practical performance trade-offs of Java's ConcurrentHashMap and concurrent queue variants.
Model answerjavaconcurrencydata-structuresmultithreadingSimulate 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.
Auto-gradedstacksimulationcommand-patternstringsReduce an absolute Unix-style path to its canonical form by resolving repeated slashes, current-directory and parent-directory segments, using a stack.
Auto-gradedstackstring-parsingsimulationpathsCount the parentheses left over after forming the maximum number of valid "(" before ")" pairs, testing a greedy counter scan or stack over a string.
Auto-gradedstackgreedystringsparenthesesReconstruct chronological function START and END lifecycle events by evaluating structural differences across consecutive call stack snapshots.
Auto-gradedstacks-queuesarraysstringsEvaluate a string of non-negative integers with +, -, *, / and spaces, honoring precedence and truncating division toward zero, without using eval.
Auto-gradedstring-parsingstackoperator-precedencesimulationWrite a linear-time evaluator for integer expressions with variables, precedence, unary signs, parentheses, truncating division and 64-bit error handling.
Model answerparsingrecursive-descentexpression-evaluationtokenizationTests stack-based parsing of nested repeat-count patterns, including multi-digit counts, nesting, and trailing letters, to rebuild the fully expanded string.
Auto-gradedstackstringparsingnested-structuresExpand 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.
Auto-gradedstackstring-parsingnested-structuresrecursionCollect 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.
Auto-gradedstackdfsiteratorsnested-listsDecide 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.
Auto-gradedstackstringsparsingScan 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.
Auto-gradedcounterbalanced-bracketssingle-passstringsFind, for each position in a sequence, the distance to the next strictly larger element, using a monotonic stack to achieve linear time.
Auto-gradedmonotonic-stackarraysnext-greater-elementBuild the lexicographically smallest subsequence that uses every distinct letter of a string exactly once, using a greedy monotonic stack with remaining-count tracking.
Auto-gradedmonotonic-stackgreedystringssubsequenceEvaluate an integer expression with +, -, *, / using standard precedence and truncating division, in a single pass over a string with arbitrary spacing.
Auto-gradedparsingstringstackoperator-precedenceImplement a lexer, recursive-descent parser and evaluator for a small integer language with variables, unary minus, precedence, truncating division and print.
Model answerparsinginterpreterrecursive-descentastEvaluate an integer expression with +, -, *, /, parentheses and unary minus in one iterative pass, using precedence rules and division that truncates toward zero.
Auto-gradedstackparsingexpression-evaluationshunting-yardCompute 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.
Model answerparsingstackstringoperator-precedenceExpand 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.
Auto-gradedstackstring-parsingnested-structuresrecursionParse a string encoding nested lists and non-negative integers into a Python list structure.
Auto-gradedstacksstringsparsingrecursionDelete exactly the brackets that cannot be paired so the remaining text is well-formed, using a single linear scan with a stack or counters.
Auto-gradedstackstringparenthesesgreedyTests 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.
Auto-gradedmonotonic-stackhash-maparraysTests stack-based parsing of nested, multi-digit repeat patterns of the form count[text] to rebuild the fully expanded string.
Auto-gradedstackstring-parsingnested-structuredecodingFind 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.
Auto-gradedsliding-windowmonotonic-dequearraystwo-pointersParse brace-delimited nested message definitions line by line, then check which dotted query paths name an actual field, tracking scope with a stack.
Auto-gradedparsingstackhash-setstringsDecide 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.
Auto-gradedstackstringsparsingAnalyze and fix a Python async script that finishes silently without invoking its async functions, and explore concurrent execution options with asyncio.
Model answerpythonasyncioconcurrencydebugging