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

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

The account is free and so is every lesson. It unlocks the courses and saves your progress.

Practice it after

The final lesson links here too: real interview questions that test this pattern, in an editor with execution and AI feedback.