Blog
Notes on data structures & algorithms, system design, and things I learn along the way.
Learning DSA? Follow the structured path — ordered articles from recursion to dynamic programming.→An agent is a while loop around a stateless API. What stop_reason really controls, why the transcript is resent on every turn, and the failure modes that show up once tools are in the mix.
Precompute once, answer range queries in O(1). How prefix sums work, the sentinel zero that removes every edge case, difference arrays for range updates, and the 2D version.
A stack that refuses to hold out-of-order values turns a pile of quadratic problems into linear ones. How the invariant works, why the amortised cost is O(n), and the four questions it answers.
Adding a cache in front of a database is easy. Deciding when the cache gets populated and how writes stay consistent with the source of truth is where cache-aside, write-through, and write-back diverge — each trading latency against staleness risk differently.
Every distributed database quietly picks a side in a trade-off it can't escape: when the network partitions, you serve either possibly-stale data or an error. CAP theorem names that choice — and explains why 'eventual consistency' is a deliberate design, not a bug.
Proxy lets you intercept fundamental operations on an object — get, set, delete, has — before they happen. It's the mechanism behind Vue's reactivity, ORMs, and API validation layers.
A regular Map keeps its keys alive forever, which turns 'metadata keyed by object' into a memory leak. WeakMap holds weak references instead, letting the garbage collector reclaim entries the rest of the program has already forgotten.
async/await isn't a new concurrency model — it's syntax sugar over promises and generators. Understanding the desugared version explains error handling, sequential-looking parallel bugs, and why 'async' functions always return a promise.
The naive substring search re-checks characters it's already seen and degrades to O(nm) on adversarial input. The Knuth-Morris-Pratt algorithm precomputes a failure table so the search pointer never moves backward, guaranteeing O(n + m).
BFS finds shortest paths when every edge costs the same. Dijkstra's algorithm generalizes that to weighted graphs by always expanding the closest unvisited node next — the algorithm behind every routing map you've used.
148 posts · page 11 of 15