DEV Community

geodesic partners
geodesic partners

Posted on Originally published at geodesicpartners.co.uk

I put my whole coding interview course online: 8 patterns, 24 problems, 6 languages

Most interview prep is a list of five hundred problems. I think that's the wrong unit to study. Interview questions are built from a small number of patterns, and once you can recognise the pattern and write its template from memory, a new problem mostly comes down to one decision: what to key on, what to keep in the window, what the state of the table is.

So the course is organised by pattern, in this order:

  1. Arrays and hashing
  2. Two pointers
  3. Sliding window
  4. Binary search
  5. Dynamic programming
  6. Stack
  7. Heap (priority queue)
  8. Backtracking

Each module starts with a lecture on why the obvious solution is too slow and what the pattern replaces it with, including an example you can step through one move at a time. Then comes the template, and then the problems, 24 in all, easy to hard. Every problem has an editor in the page, so you can try it before reading anything, and a worked solution in Python, JavaScript, C++, Java, Rust and Haskell. The solutions all run against the same tests, so none of them is a sketch.

A taste of what the lectures focus on

Sliding window is usually taught as a recipe: grow the right edge, shrink the left when the window goes bad. The part worth understanding is why that's allowed. With positive numbers, if a window's sum is over budget, every larger window containing it is over budget too, so the left edge never has to move back.

Allow a negative number and that stops being true. Look for the shortest run with sum at least 8 in [1, -5, 4, 4]: the window adds everything, peaks at a running total of 4, and reports that no such run exists, while [4, 4] is sitting right there. Knowing when a pattern breaks is what interviewers are actually checking.

The timed interview

When you've done a few modules, there's a timed mock interview. The time you get depends on the problem's difficulty, runs and submissions are limited, hints cost you marks, and at the end a report shows where the marks went.

Links

It's in early access, so some parts are still being added. If something is wrong or missing, tell me in the comments and I'll fix it.

Top comments (0)