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.→
September 14, 2026The Agent Loop: What Actually Happens Between Prompt and Answer5 min read

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.

#AI Engineering
September 13, 2026Prefix Sums and Difference Arrays: Trading Space for Constant-Time Queries4 min read

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.

#DSA
September 12, 2026Monotonic Stacks: The Pattern Behind Next Greater Element4 min read

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.

#DSA
July 18, 2026Caching Strategies: Cache-Aside, Write-Through, and Write-Back5 min read

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.

#System Design
July 18, 2026The CAP Theorem and Eventual Consistency, Explained5 min read

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.

#System Design
July 17, 2026Proxy and Reflect: Intercepting JavaScript Objects4 min read

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.

#JavaScript
July 17, 2026WeakMap and WeakSet: Memory-Safe References in JavaScript5 min read

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.

#JavaScript
July 16, 2026Async/Await Under the Hood: Promises in Disguise4 min read

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.

#JavaScript
July 16, 2026KMP String Matching: Search Without Backtracking5 min read

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).

#DSA
July 15, 2026Dijkstra's Algorithm: Shortest Paths With a Priority Queue4 min read

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.

#DSA

148 posts · page 11 of 15