Back to Notes

Week 05 — Jun 22–28, 2026 — Tries + Heap (compressed)

Week 05 (Jun 22 – Jun 28, 2026) — TRIES + HEAP (compressed)

SPRINT S1 of 8 (Jun 22 – Aug 15). New plan: finish all DSA + HLD/SD problems + Redis playlist by Aug 15, then apply mid-Aug. This week: Tries (3) + Heap (7) = 10 problems. Timer on, solo, no hints until timer expires.

→ Full curriculum: [[Coach/project_dsa_sd_curriculum]] → Coach state: [[synthesis/Coach Hub]]


Decisions applied this week (Vatsal, Jun 21)

  • Applications + referral DMs → moved to AUGUST. Tracked here, no gate this week. (Risk flagged: 90-day notice + Aug apps → offers ~Dec, tight vs Nov 11 target.)
  • DDIA → merged into SD track. No longer a separate marathon. SD-theory slot only, ongoing reading.
  • DSA → compress + slip 1 week. Tries + full Heap this week.
  • STAR reps → dropped from weekly gate. Resume before first screen.

Goals This Week

  • 10 DSA problems — done Wed Jun 24 (4 days early). 8/10 on time (621, 355 fail). ✅
  • Re-drill 2 misses — LC 23→355 merge + 621 formula (scheduled Fri Jun 26 review day)
  • SD problem: URL Shortener — ⏭️ deferred (did Rate Limiter S2 instead, 2026-07-02). Pick up URL Shortener next.
  • Redis: Intro + data types
  • DDIA: Ch6 Replication pt1 (lunch slot)
  • Sun Jun 28 scorecard + S2 direction set

DSA Problem Set (10)

Rules: timer on, no editorial/AI/peek until timer expires. One sitting per problem. Mark fail if timer expires.

#PatternProblemLCDiffTargetSolved?TimeBugs / notes
1TriesImplement Trie (Prefix Tree)208M25 minYes6:00Canonical, senior bar. Polish: extract `_find(prefix)→node
2TriesDesign Add and Search Words211M30 minYes13:00Senior bar. Reused _find helper (applied 208 feedback). .→DFS branch. Nit: any([..])→any(.. ) generator for short-circuit + no list build. start-index avoids slice copies.
3TriesWord Search II212H45 minYes24:00Senior bar — fully optimized. Trie-in-lockstep DFS + leaf-prune (del node.children[ch]) + '#' visited + is_end=False dedup + edge-word handling. Nits: mixed tuple/list dirs; matched set redundant given is_end reset. Tries bucket 3/3.
4HeapKth Largest Element in a Stream703E15 minYes3:00Senior bar. Min-heap size k, root=kth largest. heapify O(n)+trim init, add O(log k). heapq reflex cleared (W2 flag closed).
5HeapLast Stone Weight1046E15 minYes7:30Senior bar. Negate for max-heap; correct sign y-x (y more negative=larger). Trim: if x!=y: push(y-x) drops continue/else.
6HeapK Closest Points to Origin973M25 minYes9:00Senior bar. Max-heap size k, O(n log k). Nit: drop math.sqrt — compare squared dist (exact int, no float). Tie falls through to list compare (works, incidental). Alts: nsmallest, quickselect O(n).
7HeapKth Largest Element in an Array215M25 minYes5:00Senior bar (heap). Negate+heapify O(n)+pop k → O(n+k log n). Trim: pop k-1 then peek root. TODO: write quickselect O(n) cold (shared w/ 347, 973).
8HeapTask Scheduler621M30 minFail43:30Simulation correct (heap+cooldown queue, math sound) but 13 min OVER. Reached for simulation when O(N) FORMULA is canonical: max(len(tasks), (max_freq-1)*(n+1) + num_max). Drill the formula — frequency+cooldown-layout pattern. First miss of week.
9HeapDesign Twitter355M35 minFail*36:00Correct + OPTIMAL design (lazy k-way merge, self-follow, O(10 log F)). But over time + needed HINTS on getNewsFeed. Merge pattern (seed heap, pop-then-push-next) not reflex — SAME gap as LC 23 (W2, also taught). DRILL 23+355 back-to-back. Ties to S3 Twitter Feed SD (fan-out read vs write).
10HeapFind Median from Data Stream295H40 minYes9:00Senior bar, textbook. Two-heap push-low→pop-to-high→rebalance auto-sorts boundary (no num-vs-top compare). low holds extra on odd. O(log n) add, O(1) median. Solo, no hints — clean close-out.

Score: __/10 on time

Heap prereq: heapq API pre-loaded (flagged W2 fix — verify heappush/heappop/nlargest/heapify reflex before Q4).


SD + Redis Tracker (DDIA folded in)

ItemStatusNotes
SD problem: URL Shortener⬜First design problem. Components: hash/base62, KGS, DB choice, cache, redirect path, analytics.
Redis playlist: Intro + data types⬜strings/hash/list/set. S1 of 7-week Redis arc (done by S7).
DDIA reading (lunch slot)⬜Ch3 next. 1 chapter / 2 wks pace.

Applications / Referrals — DEFERRED TO AUGUST

ItemOriginal planNew plan
10 referral DMs (Splunk 5 + Amazon 5)W3 mandatoryAug W1
First 5 appsW3Aug W1
Cold apps batchW5+Aug

Nothing required this week. Pipeline opens August.


Daily Plan

Mon Jun 22

  • Tries theory block (~1h) — prefix tree structure, insert/search/startsWith, DFS-on-board for 212 ✅ 2026-06-21
  • LC 208 (25 min) ✅ 2026-06-21
  • Target: 2h

Tue Jun 23

  • LC 211, 212 (~75 min + review) ✅ 2026-06-21
  • Target: 2.5h

Wed Jun 24 ← TODAY

  • Heap theory block (~45 min) ✅ 2026-06-23
  • LC 703 (3:00), 1046 (7:30) ✅
  • LC 973 (9:00), 215 (5:00) ✅ — pulled forward
  • LC 621 (43:30 FAIL), 355 (36:00 FAIL*) ✅ attempted — pulled forward
  • LC 295 (9:00, solo) ✅ — bucket complete
  • PENDING TODAY: start SD URL Shortener (requirements + scale estimate) and/or Redis intro if energy left. DSA done — no problems owed today.

Thu Jun 25

  • SD: URL Shortener — requirements + high-level (~1h)
  • Redis: Intro + data types
  • Target: 2.5h

Fri Jun 26

  • Merge-pattern re-drill (review day): LC 23 Merge k Sorted Lists → LC 355 getNewsFeed back-to-back, solo, NO hints. Goal: seed-heap + pop-then-push-next is reflex. (Gap hit twice — W2 LC23 + S1 LC355.)
  • 621 formula cold: rewrite Task Scheduler as max(len, (max_freq-1)*(n+1)+num_max) from memory.
  • SD: URL Shortener — deep dive + trade-offs (~1h)
  • Target: 2.5h

Sat Jun 27 — heavy

  • LC 295 (hard, two-heap)
  • URL Shortener full whiteboard cold (45 min, solo)
  • Review any misses
  • Target: 4h

Sun Jun 28 — retro

  • Scorecard + W6 direction (/coach scorecard)
  • Target: 1.5h

Decision Gate (Sun Jun 28)

Score on timeVerdictS2 plan (Jun 29–Jul 5)
8–10Pass — strongS2: Backtracking (9) + Rate Limiter + Redis TTL/token-bucket
6–7Pass — patchyS2: Backtracking + retry weakest Heap
< 6FailRepeat Heap in S2, Backtracking → S3

Hours Log

DayPlannedActualWhat blocked?
Mon2h
Tue2.5h
Wed2h
Thu2.5h
Fri2.5h
Sat4h
Sun1.5h
Total17h

Week Retro (closed 2026-07-02, retro'd late — Thu)

Scorecard

  • Problems solved on time: 8/10 (2 fail: 621, 355)
  • Total solve time: ~156 min across all 10 (passes only: ~76 min); target total ~285 min
  • Both hards crushed solo: 212 (24:00/45), 295 (9:00/40)
  • Weakest: k-way lazy merge (355 — needed hints, SAME gap as LC 23 in W2) + Task Scheduler O(N) formula (621 — used simulation, blew time)
  • Strongest: heap core — 703 (3:00), 215 (5:00), 973 (9:00), 295 (9:00 hard)
LCTimeTarget
2086:0025✓
21113:0030✓
212 H24:0045✓
7033:0015✓
10467:3015✓
9739:0025✓
2155:0025✓
62143:3030✗ formula
35536:0035✗* merge+hints
295 H9:0040✓

SD / Redis / DDIA

  • URL Shortener whiteboard: ⬜ deferred (did Rate Limiter in S2 instead)
  • Redis: ✅ started — notes formatted + build-your-own topic checklist
  • DDIA Ch6 Replication: ⬜ not logged

What slipped

  • URL Shortener (SD) — swapped for Rate Limiter.
  • 2 DSA misses are pattern-recall, not solving: merge (355) + formula (621).
  • Zero cold whiteboard reps — SD is study-notes only so far.

Gate decision (8–10 = PASS STRONG)

PASS STRONG → S2 Backtracking (confirmed; already in progress).

One thing to fix in S2

Close the k-way merge gap for good: drill LC 23 → 355 back-to-back, no hints (scheduled). It's failed twice — no third.