Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Checkpoint โ€” The Amnesiac Stack

โญโญโญ advancedโณ 25 min read๐Ÿ“ Lesson 245 of 281

Min-stack protocol: pair (value, min-so-far) restores the minimum on every pop. The W is the classic single-variable min that never comes back โ€” the amnesia the pop-heavy test exposes.

Checkpoint โ€” The Amnesiac Stack. The min-stack is the canonical 'carry the aggregate in the state' structure: each stack entry stores (value, min-from-bottom-to-here), so a pop restores the previous minimum automatically. The W keeps a single global min variable and never restores it โ€” after the minimum is popped, every future ask reports a value that is no longer in the stack. The pop-heavy test is the harness discipline made concrete: trace pops twice before trusting.