Stacks Quiz
Editorial
16 questions across the five Stacks lessons: the basics, matching brackets, expressions, and monotonic stacks for next greater elements and for ranges. Pick an answer to see whether it's right and why. Nothing is saved, so you can take it again.
If one trips you up, its lesson is Introduction to Stacks, Matching Brackets with a Stack, Evaluating Expressions with Stacks, Monotonic Stack: Next Greater and Smaller Elements or Monotonic Stack: Subarray Minimums and Histograms.
Quiz
1 / 16Multiple choice
Push 5, push 8, pop, push 1, push 6, pop, pop. In what order do the values come off?
Multiple choice
A queue made of two stacks pours
in into out only when out is empty. Push 1, push 2, pop, push 3, pop. Which values come out?Multiple choice
A min stack keeps a second stack of minimums, adding a value there only when it's strictly smaller than the current minimum, and removing it there when it's popped. Push 2, push 2, pop, then get the minimum. What happens?
Multiple choice
Asteroid Collision on [5, -3, -6, 2]: what's left?
Multiple choice
Minimum Remove to Make Valid Parentheses on
(a(b): which answers remove the fewest brackets?Multiple choice
Simplify Path on
/a/./b/../../c/?Multiple choice
What does the postfix
8 2 - 3 / evaluate to?Multiple choice
Shunting yard on
a*(b+c)-d: what's the postfix?Multiple choice
Basic Calculator II on
2-3*2+1?Multiple choice
Next greater element of each value in [2, 7, 3, 5, 4, 6, 8], −1 if there's none?
Multiple choice
Next Greater Element II, where the array wraps around, on [3, 1, 2]?
Multiple choice
Remove K Digits with num =
14329 and k = 2?Multiple choice
Online Stock Span gets prices 7, 2, 1, 4, 3, 6, one a day. What's the span on the day of 6?
Multiple choice
Sum of Subarray Minimums on [3, 1, 2]?
Multiple choice
Largest Rectangle in Histogram on [2, 4, 4, 1, 3]?
Multiple choice
Trapping Rain Water on [3, 0, 1, 0, 2]: how much water is held?