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.→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.
Calendar conflicts, meeting rooms, and 'maximum non-overlapping tasks' are all interval problems that collapse into a single sort-then-scan pattern once you pick the right key to sort by.
A probabilistic data structure that answers set-membership queries in constant space by allowing false positives but never false negatives — and why Chrome, Cassandra, and CDNs all rely on that trade.
When an array changes and you still need fast range sum, min, or max queries, prefix sums stop working. Segment trees answer both range queries and point updates in logarithmic time.
One template solves permutations, subsets, N-Queens, and Sudoku. Learn the choose–explore–unchoose pattern and how pruning turns exponential search into something usable.
What Big-O actually measures, how to read a function's complexity straight from its shape, and why O(n log n) beats O(n²) long before n gets big.
LIFO and FIFO look trivial until you notice they power your call stack, undo history, browser navigation, and every BFS. Plus the classic interview patterns for each.
Build systems, package managers, and course schedulers all answer the same question: what order satisfies every dependency? Kahn's algorithm answers it — and detects impossible cycles.
The disjoint set union structure answers 'are these two connected?' in near-O(1) — with two optimizations you can write in twenty lines. Includes Kruskal's MST and cycle detection.
The operators every developer half-remembers — AND, OR, XOR, shifts — and the handful of tricks that turn them into fast, elegant solutions.
The data structure behind autocomplete and spellcheck. How a trie stores words as shared character paths, and why lookups cost the length of the word — not the size of the dictionary.
How a heap keeps the smallest (or largest) element one lookup away, why it's stored in a plain array, and the sift-up/sift-down operations that keep it valid.
Why linked lists still matter, and the two-pointer trick that detects a loop in one pass with no extra memory — the famous tortoise and hare.
DP is not a scary black box — it's recursion that stops repeating itself. Follow one problem from exponential recursion to a linear table, one cell at a time.
Breadth-first and depth-first search are the same algorithm with one data structure swapped. See both walk the same graph, and learn which to reach for.
Recursion feels like magic until you see the call stack. Here's the mechanical picture — frames pushing and popping — plus base cases, stack overflows, and tail calls.
Two of the highest-leverage array patterns in interviews and real code — how they turn nested O(n²) loops into a single O(n) pass, and when each one applies.
How binary search eliminates half the problem with every comparison, and how binary search trees turn the same idea into a data structure — with interactive animations.
How hash maps actually work — hashing, buckets, collisions, and resizing — with an animated walkthrough and a from-scratch implementation.
Why the classic interview question is really a lesson in composing data structures — with an animated walkthrough and two working implementations.
A visual walkthrough of quick sort and heap sort — how partitioning and heaps achieve O(n log n) without merge sort's extra memory, with animated demos and code in Java and JavaScript.
A visual, hands-on walkthrough of four classic sorting algorithms with animated demos and code in both Java and JavaScript.