Daily Temperatures

Monotonic stack · Keep unresolved candidates ordered · Stretch · about 25 min

Why it matters

The “next greater item” family appears often in interview rounds.

How it connects

A normal stack remembers nesting. A monotonic stack remembers unresolved days in useful order.

Try first

Which earlier days are still waiting for a warmer temperature when you read today?

Interview cue

Each index is pushed once and popped once, despite the nested-looking loop.