Monotonic Stack Template
Aug 13, 2025 · 6 min read · The Core Idea A monotonic stack is just a stack that keeps its elements in sorted order (increasing or decreasing).When a new element breaks the rule, we pop until the rule is happy again. Why store indices instead of values?Because we often need to ...
Join discussion
