basecase · interview notes

Practice

Coding rounds without grinding

Most of the value is in a small number of patterns practised badly on purpose — spaced out, from a blank page, out loud.

The default advice is to solve a large number of problems. I did that, and it worked less well than the hours suggested it should. The failure mode is specific and easy to miss: solving a problem you have seen recently exercises recognition, not retrieval, and recognition is not what the interview asks for. You feel fluent and you are only familiar.

What I would do instead, in order of how much it mattered:

  1. Cover the pattern inventory once, carefully. There are perhaps a dozen shapes that account for the large majority of what gets asked. Cover them slowly enough to understand why each one works, not just what its code looks like.
  2. Re-solve, don't re-read. Come back to a problem three or four weeks later and write it again from an empty file. If you can, you know it. If you can only recognise the trick, you do not.
  3. Practise out loud, alone if necessary. The narration is a separate skill from the solving, it is scored, and it competes for working memory. Practising them together is the only way to find out how much it costs you.
  4. Write in a plain editor with no completion. Interview editors have no autocomplete, no type checking, and no run button. Discovering how much you leaned on those is better done in your own room.

The inventory

Roughly ordered by how often I have seen each one asked or asked it myself. The point of a list like this is not to memorise it — it is to notice when you have a gap that you have been quietly avoiding for months.

PatternRecognise it byTypical cost
Hash map countingAnything about duplicates, frequencies, pairs summing to a targetO(n)
Two pointersSorted input, or a partition you can maintain from both endsO(n)
Sliding windowLongest or shortest contiguous run satisfying a propertyO(n)
Binary searchSorted array — or a monotone predicate over an answer rangeO(log n)
Sorting firstIntervals, scheduling, anything where order removes a caseO(n log n)
Heap / top-k"K largest", streaming medians, merging sorted sourcesO(n log k)
Graph BFSShortest path with uniform edge cost, level-by-level spreadO(V+E)
Graph DFSConnectivity, cycle detection, topological orderO(V+E)
Tree recursionAnything on a binary tree; usually a post-order return valueO(n)
BacktrackingEnumerate all valid arrangements; permutations, subsets, boardsexponential
1-D dynamic programmingOverlapping subproblems along one index; "ways to", "minimum cost to"O(n)
2-D dynamic programmingTwo sequences compared, or a grid with choices at each cellO(nm)
Union-findMerging groups, connectivity queries in any ordernear O(1)
Prefix sumsRepeated range queries over a static arrayO(1) per query
Monotonic stackNext greater or smaller element, spans, histogramsO(n)

Two entries on that list are worth more attention than the rest, because they are where under-prepared candidates most often stall: binary search over an answer range rather than an array, and dynamic programming stated as a recurrence before any code is written. Both are learnable in an afternoon each and both come up far more than their reputation suggests.

A practice schedule that survives a job

The schedule below assumes an hour a day, which is what I could actually sustain. It is built around returning to problems rather than accumulating them.

weeks 1–2

One pattern per day from the inventory. Two problems each: one worked through with the explanation open, one attempted cold. Keep a one-line note per problem recording the idea, not the code.

weeks 3–4

Mixed sets of three problems with the pattern label hidden. This is the first honest test — in an interview nobody tells you which drawer to open, and picking the drawer is most of the difficulty.

weeks 5–6

Timed, narrated, from an empty file. Forty-five minutes, speaking throughout, no run button. Re-solve anything from week 1 that you have not touched since, and expect to be humbled by at least one of them.

ongoing

Two or three problems a week, always mixed, always cold. Add anything you failed back into the queue three weeks out rather than immediately.

If you take one thing from this page: the review interval is the active ingredient. A problem re-solved after three weeks is worth several solved once. The discomfort of having forgotten something you "knew" is not a sign the practice is failing — it is the practice working.

Structuring the forty-five minutes

Roughly, and adjusting for how much the interviewer talks:

Failure modes I saw most often

Next: system design without hand-waving.