Visual walkthrough

Flowchart from Monotonic Stack / Deque. Shows Stack state at i=4 (decreasing order top↑), idx 2, 71 idx 3.

More from Monotonic Stack / Deque