Monotonic Stack / Queue Ladder¶
This ladder is for learning when one linear scan plus one domination rule is enough, so you do not overbuild a heavier range-query structure.
Who This Is For¶
Use this ladder when:
- nearest greater / smaller logic still turns into nested loops
- every sliding-window max/min problem looks like a heap or multiset problem first
- you want a cleaner boundary between monotone scans and real online data structures
Warm-Up¶
- next greater / smaller
- previous greater / smaller
Core¶
- histogram-style boundary scans
- fixed-width window extrema
- proving the
push once, pop onceamortized bound
Exact Repo Route¶
- stack-side starter -> monotonic-stack-nearest-smaller.cpp
- queue-side starter -> monotonic-deque-min.cpp
- flagship in-lane rep -> Nearest Smaller Values
- queue-side compare rep -> Sliding Window Minimum
- stretch sibling -> histogram / rectangle boundary tasks such as
Advertisement