Least You Need to Know: Monotonic Stacks and Next-Greater Patterns
開啟課程
A monotonic stack keeps elements in sorted stack order so that a new value can resolve many waiting positions at once. This turns repeated scanning into a single left-to-right pass for next-greater and waiting-time style problems.