Coding: the 6 step method0/59 done

The 6 step method (say it out loud)

Interviewers grade how you think as much as the code. Narrate everything.

1. Repeat"So I get X and return Y." Confirms you understood.
2. ClarifyEmpty input? Duplicates? Negatives? Sorted? Size of n? Can I modify the input?
3. ExampleWalk one small example by hand, plus one edge case.
4. Brute forceSay it with its Big O. Don't code it unless asked.
5. Improve, then codeName the pattern ("hash map", "two pointers"). Code it clean, with good names.
6. TestRun your example through the code line by line. Then edge cases. Then state time and space.

Which pattern? Look at the input

If you seeTry
"Have I seen this?", counts, pairsMap or Set
Sorted array, palindrome, in-place rewriteTwo pointers
Best substring or subarraySliding window
Matching pairs, nesting, "most recent"Stack
Sorted plus find, or "minimum X that works"Binary search
Tree depth or pathRecursion (DFS)
Level by level, fewest stepsBFS with a queue
Grid, connected areasDFS or BFS flood fill
Ranges, meetings, schedulesSort by start, then merge
"How many ways", best value from smaller casesDP

When stuck