Stack Discipline Target: 15s
Stack = most recent first (nesting, matching). Queue = oldest first (BFS, scheduling). Deque = both ends.
STACK (LIFO) vs QUEUE (FIFO)
────────────────────────────
STACK — Last In, First Out:
"most recent" / "nested" / "matching"
□ Parentheses matching
□ Undo/redo
□ DFS traversal (explicit stack)
□ Monotonic stack (next greater element)
□ Expression evaluation
□ Call stack simulation
QUEUE — First In, First Out:
"earliest" / "level-by-level" / "waiting line"
□ BFS traversal (shortest path)
□ Level-order tree traversal
□ Task scheduling (FIFO order)
□ Sliding window max (deque)
□ Rate limiting (timestamp queue)
DEQUE — both ends:
□ Sliding window maximum
□ BFS optimizations
□ Palindrome check
PRIORITY QUEUE (heap):
□ "Next best" / "top K" / "median"
□ Dijkstra, merge K sorted lists
Type it from memory. Go.