Learn
DSA Patterns
The recurring shapes behind interview problems — what each pattern is, when it applies, the template that solves it, and the mistakes that cost people the round.
Articles22
Backtracking
3 minChoose, recurse, un-choose. One template generates every subset, permutation and combination — pruning is what makes it fast.
Bitwise XOR
4 minFour algebraic properties turn 'find the unpaired number' into a one-line O(1)-space scan.
Breadth First Search (BFS)
3 minA queue, a visited set, and level-by-level expansion — the shortest path on any unweighted graph.
Cyclic Sort (Index-Based)
3 minWhen the values are 1..n, the array is its own hash map — swap each value home and read off what is missing.
Depth First Search (DFS)
3 minGo deep, backtrack, repeat — the pattern behind islands, flood fill, and every connectivity question.
Design Data Structure
3 minEvery answer is two structures combined — a hash map for lookup plus something that maintains order.
Dynamic Programming
4 minDefine the state, write the recurrence, memoise, then tabulate. Five families cover almost every DP question asked.
Fast and Slow Pointer
4 minTwo pointers at different speeds. Detects cycles, finds middles, and locates duplicates in constant space.
Graphs
4 minTopological sort, Dijkstra, union-find and MST — which one a question needs, and the template for each.
Greedy
3 minTake the best local choice and never reconsider — when you can prove that choice is safe.
K-way Merge
3 minA heap holding one candidate per list — the smallest overall is always the heap root.
Matrix Manipulation
3 minRotation is transpose plus reverse, spiral is four shrinking boundaries, and a sorted grid is a 1-D binary search.
Modified Binary Search
4 minOne boundary template, then the two hard variants: rotated arrays, and searching the answer space instead of the input.
Monotonic Stack
4 minA stack kept in sorted order answers every 'next greater element' question in one O(n) pass.
Overlapping Intervals
3 minSort by start, then merge in one pass — plus the heap and sweep-line variants for counting concurrent intervals.
Prefix Sum
3 minPrecompute running totals once, answer any range query in O(1) — and count target-sum subarrays in one pass.
Reversal of Linked List (In-place)
2 minThree pointers, one pass, no extra memory — and the dummy node that makes the sublist variants tractable.
Sliding Window
7 minTurn an O(n²) scan of every subarray into one O(n) pass — and learn to spot the problems where that works.
Top 'K' Elements
3 minKeep a size-K heap of the opposite type — min-heap for largest, max-heap for smallest. O(n log k), not O(n log n).
Trees
4 minFour traversals, one recursion template, and the two BST facts that answer half the questions.
Two Heaps
3 minSplit the data at the median — max-heap below, min-heap above. The answer is always at the two tops.
Two Pointers
3 minOne pointer at each end, converging. Turns the O(n²) pair search into a single sorted pass.
Topics22
Every topic on the 22 DSA Patterns sheet, in the order the sheet works through them. 22 of 22 have a written guide so far — the rest link straight to their questions on the sheet.
- Fast and Slow PointerGuide
- Overlapping IntervalsGuide
- Prefix SumGuide
- Sliding WindowGuide
- Two PointersGuide
- Cyclic Sort (Index-Based)Guide
- Reversal of Linked List (In-place)Guide
- Matrix ManipulationGuide
- Breadth First Search (BFS)Guide
- Depth First Search (DFS)Guide
- BacktrackingGuide
- Modified Binary SearchGuide
- Bitwise XORGuide
- Top 'K' ElementsGuide
- K-way MergeGuide
- Two HeapsGuide
- Monotonic StackGuide
- TreesGuide
- Dynamic ProgrammingGuide
- GraphsGuide
- GreedyGuide
- Design Data StructureGuide
Related
22 DSA Patterns sheet
Practise the topics above and track what you have solved.
SQL articles
Query topics as they actually come up in interviews — joins, window functions, CTEs and the analytics patterns built on them, each with runnable queries.
System Design articles
Design problems worked end to end: requirements, back-of-envelope numbers, the architecture, and the trade-offs an interviewer will push on.