← Hub
Interview Coach
Pattern Gym
Structure first. Explain before code. Syntax is optional shape at the end.
For each pattern: learn the signal, do the coach card, then (only if the rubric is strong)
implement in a blank Xcode playground without Cursor.
LRU Cache
When you reach for it
- Need get/put fast, and evict least recently used at capacity
- Interview signal: "O(1)" + "recently used"
Mental model
- Map: key to node (find instantly)
- Doubly linked list: recency order (move/remove instantly)
- Most recent near head; least recent near tail
- Dummy head/tail = fewer null edge bugs
Hand walk: capacity 2.
put(1,a) list: 1
put(2,b) list: 2-1
get(1) moves 1 front: 1-2
put(3,c) evicts 2, list: 3-1
Hash map
When you reach for it
- "Have I seen this value before?"
- Pair / complement problems (two-sum family)
- Group by signature (anagrams)
Mental model
- Trade space for lookup speed
- Brute force is usually nested loops
- Key choice matters (value vs index vs signature)
Two-sum hand walk: nums=[2,7,11], target=9.
see 2, need 7, store 2->0
see 7, need 2, map has 2 -> return [0,1]
Two pointers
When you reach for it
- Sorted array pair problems
- Contiguous window (expand/shrink)
- In-place rearrange from both ends
Mental model
- Left/right move from a condition; no full restart
- Often O(1) extra memory vs map
- If unsorted and need arbitrary lookup, map may win
Stack
When you reach for it
- Nesting / matching (parentheses)
- "Previous smaller/greater" monotonic stack family
- Undo / path collapse
Mental model
- LIFO: last unresolved opener must resolve first
- A count alone cannot validate mixed bracket order
Walk: "([])"
push (, push [, pop on ] match, pop on ) match, empty = valid
Linked list pointers
When you reach for it
- Reverse, merge, cycle, remove nth
- Any problem where rewiring
next is the work
Mental model
- Save
next before overwrite
- Name roles: prev / curr / nextTemp
- Dummy nodes remove head/tail special cases
BFS vs DFS
When you reach for it
- BFS: shortest path / levels in unweighted graphs
- DFS: explore paths, tree recursion, cycle detection with state
Defensive talk track
Apple-style coding grades how you protect the happy path. Practice announcing edges before you type.