Stack Behavior
Know
A stack pushes and pops at one end, so the most recent item leaves first. That ordering is what makes it match nesting, backtracking, and call stacks.
Apply
Reach for a stack whenever the problem involves matching pairs or undoing recent work.
Watch out
Treating a stack as a general list and indexing into it, which discards the guarantee that makes it useful.
Study move
Use a stack to check bracket balance and state both failure conditions.
