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.→
October 18, 2026Flood Fill and Number of Islands: Graphs Hiding in Grids4 min read

A grid is a graph: each cell is a node, and its neighbours are its edges. How flood fill (the paint-bucket tool) and 'number of islands' are BFS or DFS over that implicit graph, how to avoid stack overflows and revisits, and the family of grid problems the same template solves.

#DSA
October 18, 2026Huffman Coding: Compression with a Greedy Algorithm3 min read

Give frequent symbols short codes and rare ones long codes. How Huffman's algorithm builds an optimal prefix code by repeatedly merging the two least frequent symbols with a min-heap, why no code is a prefix of another, and where Huffman coding still runs today — inside gzip, PNG and JPEG.

#DSA
October 18, 2026Longest Palindromic Substring: Expand Around the Centre3 min read

Find the longest substring that reads the same forwards and backwards. Why checking every substring is O(n³), how expanding around each of the 2n − 1 centres gives a simple O(n²) solution with O(1) memory, the DP alternative, and where Manacher's linear-time algorithm fits.

#DSA
October 18, 2026Maximum Flow: Edmonds–Karp and the Min-Cut Theorem4 min read

How much can flow through a network of pipes with limited capacities? How augmenting paths found by BFS push flow until none remain, why residual edges let the algorithm undo earlier choices, how the max-flow equals the min-cut, and the matching and assignment problems that reduce to it.

#DSA
October 17, 2026Sweep Line: Solving Overlap Problems by Sorting Events3 min read

Turn every interval into a start event and an end event, sort them, and walk through with a running count. How the sweep-line technique answers 'how many meeting rooms?', 'when was the system busiest?' and the skyline problem in O(n log n), and the tie-breaking rule that decides correctness.

#DSA
October 16, 2026Bipartite Graphs and Two-Colouring3 min read

Can a graph's nodes be split into two groups so every edge crosses between them? How a BFS that alternates two colours answers it in linear time, why the answer is 'no' exactly when there's an odd cycle, and the problems that are secretly this one — from scheduling to splitting people into teams.

#DSA
October 16, 2026Bitmask DP: Solving the Travelling Salesman for Small n4 min read

When a DP state has to remember which items have been used, a bitmask can encode the set in one integer. How that turns the travelling salesman problem from n! routes into 2ⁿ·n states, the bit tricks you need, and how to recognise problems where n ≤ 20 is a hint.

#DSA
October 16, 2026K-Way Merge: Combining Sorted Lists with a Heap3 min read

Merging k sorted lists into one by repeatedly taking the smallest head — with a min-heap so each step costs O(log k). The pattern behind merge-sort's final pass, external sorting of files bigger than memory, LSM-tree compaction, and a family of interview problems.

#DSA
October 16, 2026Longest Common Subsequence: The Algorithm Behind diff5 min read

The longest sequence of items two lists share in order, not necessarily side by side. How a small DP table finds it, how walking back through the table recovers it, and how the same idea — applied to lines instead of letters — produces the diffs you read in every code review.

#DSA
October 16, 2026Lowest Common Ancestor with Binary Lifting4 min read

The deepest node that is an ancestor of two given nodes in a tree. The simple walk-up solution, then binary lifting: precompute every node's 1st, 2nd, 4th, 8th… ancestor so any query takes O(log n) jumps. With distances between nodes and the k-th ancestor as bonuses.

#DSA

51 posts tagged DSA · page 1 of 6