Min Stack

Stack · Store an answer alongside each item · Easy · about 20 min

Why it matters

Augmenting a data structure with one extra fact is a powerful design move.

How it connects

A stack already preserves order. Now enrich each entry with the minimum so far.

Try first

When a value is pushed, what minimum should be remembered with it?

Interview cue

Saving the minimum at push time makes getMin O(1) without scanning.