Lab
Engineering reference for step-by-step algorithm traces, Pareto Python templates (20), pattern triage breakdowns (48), and distributed system design scenarios (2).
System Design
Capacity sizing math, layer-by-layer architectural trade-offs, failure scenario evaluations (shard crash, hot key, stampede, 32k LLM burst), and architecture trade-off notes.
Coding Patterns
Reusable Python templates (20) with step-by-step traces, pattern triage breakdowns (48) with translation notes, and interactive buggy code traces (3).
Interactive System Design Guides
Interactive Trace Directory
Longest substring without repeating characters, explained by the one reason it is O(n) and not O(n²).
Stop memorizing off-by-one fixes. Watch the one fact that stays true on every step and the code writes itself.
Eliminate an entire row or column of pairs on every step by exploiting sorted order.
Turn O(n²) subarray sum searches—even with negative numbers—into one O(n) pass.
Resolve 'next warmer / next shorter' queries in O(n) by keeping waiting indices strictly ordered.
Maintain a double-ended queue of indices in monotonic order to query sliding-window max/min in O(1) amortized time per step.
Why finding the K largest items in a 10M-event stream uses a MIN-heap capped at size K.
Split a stream into a max-heap lower half and min-heap upper half to maintain the live median in O(log n) per insert and O(1) per query.
Enqueue all starting sources at distance 0 to compute minimum wave time on unweighted graphs and grids.
Swap BFS's queue for a min-heap to find minimum-latency routes across non-negative weighted networks.
Schedule directed prerequisites and detect circular dependencies in O(V + E) using indegree counts.
Merge clusters and answer 'are these two servers connected?' almost instantaneously as edges stream in.
Compute tree-wide optima (max path sum, diameter, LCA) by returning a single extendable branch while updating a two-branch split answer.
Sort by start timestamp once, then resolve every overlap with a single linear sweep.
Share common character prefixes as tree edges so lookup speed depends only on query length, never dictionary size.
Combine a Hash Map and Doubly Linked List to get O(1) get, O(1) put, and O(1) eviction—a bridge between coding and system design.
Replace O(n²) DP with a single running frontier when local progress never hurts future options.
Systematically enumerate every valid subset, permutation, or configuration by mutating and unwinding one shared path.
Compute globally optimal answers from strictly smaller solved states whenever greedy choices can trap you.
Compare or align two sequences (LCS, Edit Distance, Regex Matching) on an (n + 1) × (m + 1) table indexed by prefix lengths (i, j).
Upcoming System Design Notes
pnpm new:lab "Design X" --kind systemContinuous batching, PagedAttention KV-cache memory blocks, prefix caching, and TTFT vs TPOT latency trade-offs at OpenAI scale.
Enforce per-tenant RPM and TPM quotas for an AI API gateway without adding a synchronous bottleneck on every request.
Approximate nearest neighbors with HNSW graph layers, quantization, scatter-gather sharding, and recall vs latency budgets.
Two-stage candidate generation and ranking, online/offline feature store skew prevention, and freshness caches at Netflix scale.
20 algorithm traces with step-by-step code notes and variable watches, 1 distributed KV cache guide, 2 system design scenarios, and 48 pattern-mapping prompts.