Cohort 4Register

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.

PATTERNS TO WRITE COLDCHEAT SHEET
# 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

NeedReach forCost
Look something up by keydictO(1) average
Is x in the collection?setO(1) average
Add and remove at both endscollections.dequeO(1)
Smallest or largest kheapqO(n log k)
Huge input, one passgeneratorO(1) memory

The last 48 hours

WhenDo thisSkip this
2 days beforeRedo 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 beforeOne timed mock out loud. Re-read the traps. Check your setup: editor, camera, network.Grinding problems late into the night.
In the roomSay 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

  1. Write the patterns on the cheat sheet from memory, then compare.
  2. Pick three patterns and solve their Coding Practice questions again without hints.