AAlgoLoopSpaced repetition for LeetCode

Monotonic Stack

A monotonic stack keeps its elements in sorted order, popping any that violate it as you scan. It answers 'next greater' or 'next smaller element' style questions in O(n) instead of O(n²).

7 LeetCode problems solved with the Monotonic Stack pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →