PART 7 · PRACTICE, PREP FLOW AND REVISION
Revision sheet and the last 48 hours
FreeLesson 78 of 78
Read this the night before the interview. Everything on it is covered in detail somewhere in the previous 79 pages.
# count / group / dedupe (P1, P3, P4)
counts[k] = counts.get(k, 0) + 1
groups.setdefault(k, []).append(row)
if k not in best or row["ts"] > best[k]["ts"]:
best[k] = row
# top k (P2)
heapq.nlargest(k, items, key=lambda x: x[1])
# window (P5)
win.append(x); total += x
if len(win) > k: total -= win.popleft()
# streak start (P9)
if d - ONE_DAY not in days: ...
# merge intervals (P11)
if out and s <= out[-1][1]:
out[-1][1] = max(out[-1][1], e)
# stream a big file in batches (P13)
while batch := list(islice(rows, n)): ...
# retry (P14)
time.sleep(random.uniform(0, min(cap, base * 2 ** n)))Pick the structure
| Need | Reach for | Cost |
|---|---|---|
| Look something up by key | dict | O(1) average |
| Is x in the collection? | set | O(1) average |
| Add and remove at both ends | collections.deque | O(1) |
| Smallest or largest k | heapq | O(n log k) |
| Huge input, one pass | generator | O(1) memory |
The last 48 hours
| When | Do this | Skip this |
|---|---|---|
| 2 days before | Redo your 10 "failed" tracker problems cold. Read pages 4, 78 and 80. | New topics. You will not learn graphs well in two days. |
| 1 day before | One timed mock out loud. Re-read the traps. Check your setup: editor, camera, network. | Grinding problems late into the night. |
| In the room | Say the I/O, edge cases and brute force before coding. State Big-O at the end. Test one edge case by hand. | Typing in silence, or going quiet when stuck: say what you are trying. |
Practice before you move on
- Write the patterns on the cheat sheet from memory, then compare.
- Pick three patterns and solve their Coding Practice questions again without hints.