Interview Prep
Coding Patterns
Most coding-interview questions are variations of a small set of patterns. Learn to recognise each one, a reusable template in Java, Python and TypeScript, worked examples, and a curated practice list.
7 modules 25 lessons ~1 h of reading
Start learning
0/25 completed
01
Start Here
1 lessons02
Array & String Patterns
8 lessons- 2Two PointersTwo indices moving through a sequence — from both ends or in the same direction — to replace O(n²) pair searches with O(n).beginner2 min
- 3Fast & Slow PointersFloyd's tortoise and hare — detect cycles, find the cycle start, the middle node, and duplicates in O(1) space.beginner2 min
- 4Sliding WindowMaintain a contiguous window that grows and shrinks to find the best subarray or substring in a single O(n) pass.intermediate2 min
- 5Prefix SumPrecompute running totals to answer any range-sum in O(1) — and combine with a hash map to count subarrays in O(n).beginner2 min
- 6Merge IntervalsSort by start, then sweep — merge overlaps, insert intervals, find free time and count the rooms needed.intermediate2 min
- 7Cyclic SortWhen values are in the range 1..n, put each number at its own index in O(n) — then missing and duplicate numbers jump out.beginner2 min
- 8Monotonic StackA stack kept in increasing or decreasing order answers every "next greater / smaller element" question in O(n).intermediate2 min
- 9Modified Binary SearchBinary search beyond "find x" — rotated arrays, peaks, 2D matrices, infinite arrays, and searching the answer space.intermediate2 min
03
Linked List Patterns
1 lessons04
Tree & Graph Patterns
6 lessons- 11Tree Breadth-First SearchProcess a tree level by level with a queue — level order, zigzag, right side view, minimum depth and connecting levels.beginner2 min
- 12Tree Depth-First SearchRecursive tree solutions — path sums, root-to-leaf paths, LCA, diameter and max path sum, using the "return up, update global" recipe.intermediate2 min
- 13Graph Patterns (Grids, Islands, BFS & DFS)Flood fill, counting islands, multi-source BFS, shortest paths in grids, and cloning — the graph problems interviews love.intermediate2 min
- 14Topological Sort PatternOrder things with dependencies — course schedules, build orders, alien dictionaries — with Kahn's in-degree BFS.intermediate2 min
- 15Union-Find PatternSpot problems about merging groups and dynamic connectivity — redundant connections, provinces, accounts merge, Kruskal.intermediate2 min
- 16Trie PatternPrefix problems — autocomplete, word search on a board, replace words, and XOR maximisation with a binary trie.intermediate2 min
05
Heap Patterns
3 lessons- 17Two HeapsKeep a max-heap of the smaller half and a min-heap of the larger half to get running medians and balance two choices.advanced2 min
- 18Top K ElementsFind the k largest, smallest, most frequent or closest items with a size-k heap, bucket sort or quickselect.intermediate2 min
- 19K-way MergeMerge k sorted lists or search across sorted rows with a min-heap of the current heads — kth smallest in a matrix, smallest range.intermediate2 min
06
Search Space Patterns
3 lessons- 20Subsets & BacktrackingOne template for subsets, permutations, combinations, partitions and constraint puzzles — choose, explore, un-choose.intermediate2 min
- 21Bitwise XORUse x ^ x = 0 to find missing and single numbers, split two unknowns by a differing bit, and solve subarray XOR problems with prefix XOR.intermediate2 min
- 22Greedy PatternRecognise interview problems where a local choice is provably optimal — jump game, gas station, interval scheduling, candy, and when greedy fails.intermediate3 min
07
Dynamic Programming Patterns
3 lessons- 23Knapsack DPThe 0/1 and unbounded knapsack patterns — subset sum, partition, target sum, coin change — and the loop direction that separates them.advanced3 min
- 24DP on SequencesLinear DP (house robber, decode ways), longest increasing subsequence, two-sequence DP (LCS, edit distance) and state machines (stock problems).advanced3 min
- 25DP on Grids & IntervalsGrid path DP (unique paths, minimum path sum, maximal square) and interval DP (palindromes, burst balloons, matrix-chain) with the right fill order.advanced2 min