Stacks & Monotonic Stacks

Last in, first out: the right tool whenever the most recent thing matters most.

5 lessons · ~48 min · free

By the end you can

Lessons

  1. 1Last in, first out8 minPush, pop, and why undo buttons, call stacks, and matching problems all share one shape.
  2. 2Matching and nesting10 minValid parentheses done right: the most recent open bracket is the only one that can close.
  3. 3Monotonic stacks12 minNext greater element and daily temperatures: a stack of values still waiting for their answer.
  4. 4Unfolding nested structures10 minDecode-string style problems: a stack per nesting level, and the recursion it quietly replaces.
  5. 5Spotting stack problems8 minThe cues for plain and monotonic stacks, the increasing-or-decreasing decision, and the templates.

Practice it after

Real interview questions that test this pattern, in an editor with execution and AI feedback.