Monotonic Stack Template
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 ...
himanshukumardatastructurealgorithm.hashnode.dev6 min read