WorkspaceLearning path
Level 2 · Core Data Structures
BUILD YOUR INTUITION

Stack

The most recent unfinished task must be resolved first.

THE MENTAL MODEL

When should this come to mind?

The most recent unfinished task must be resolved first.

Nested matchingLast-in-first-outPrevious greater or smallerUndo

What makes it work

Push and pop from the same end; always handle an empty stack.

When to choose something else

Processing in arrival order calls for a queue.

See the pattern in action

Change the input. Follow the state. Make it yours.