Data Structures & Algorithms
Crack the coding interview: build every data structure from scratch, master the patterns, from arrays and hashing to graphs and dynamic programming.
10 projects, 250 hands-on levels, run in your browser.
Syllabus
- Complexity, Arrays & Hashing: Every interview starts here. Learn to reason about cost with Big-O, get fluent with the array techniques that show up everywhere (prefix sums, in-place two pointers, Kadane), then unlock the single most useful tool in the interview toolkit: the hash map. By the end you can turn brute-force O(n squared) scans into clean O(n) solutions.
- Two Pointers & Sliding Window: Two of the highest-yield interview patterns. Two pointers walk an array from both ends or at two speeds to solve in O(n) what looks like it needs O(n squared). The sliding window keeps a running answer over a moving range so you never recompute from scratch. Master these and a huge slice of array and string problems fall.
- Stacks, Queues & Strings: Build the two simplest data structures from scratch, then wield them. A stack (last in, first out) powers parsing, matching, and the monotonic-stack pattern that answers 'next greater element' in O(n). A queue (first in, first out) drives order-preserving simulations. Along the way, sharpen the string-processing reflexes interviews lean on.
- Binary Search & Sorting: Sorted data is a superpower. Binary search halves the search space each step for O(log n) lookups, and the same idea generalizes to searching over an answer (the smallest speed, the least capacity). Build the classic sorts to own divide-and-conquer, then apply sorting to the interval problems that show up constantly.
- Linked Lists: A linked list trades random access for cheap insertion and the pointer-rewiring skills interviewers love to probe. Build the node, traverse it, then master the moves: reverse, find the middle and cycles with fast and slow pointers, merge, reorder, and build an LRU cache. Finish by sorting a list with merge sort.
- Trees & Binary Search Trees: Trees turn recursion into a reflex. Build a binary tree, traverse it depth-first and breadth-first, then reason about depth, balance, and diameter. Add the ordering invariant of a binary search tree to get O(log n) lookups, and finish with the path and ancestor problems interviewers love.
- Heaps, Priority Queues & Tries: Two specialist structures with huge payoff. A heap keeps the smallest (or largest) element one O(log n) operation away, which is the key to top-K, streaming medians, and merging. A trie stores strings by shared prefix for fast lookup and autocomplete. Build each from scratch, then reach for the library version.
- Graphs & Advanced Graphs: Graphs model everything with relationships, and most graph interview problems are a traversal in disguise. Build the adjacency list, traverse with BFS and DFS, flood-fill grids, order tasks with topological sort, group with union-find, and find shortest paths with Dijkstra. The patterns here unlock a whole tier of problems.
- Recursion, Backtracking & Greedy: Two ways to make decisions. Backtracking explores every choice, undoing each before trying the next, which generates subsets, permutations, and solves constraint puzzles. Greedy commits to the locally best choice and never looks back, which is faster but only correct for the right problems. Learn to wield both, and to tell them apart.
- Dynamic Programming + Capstone: The pattern that scares candidates most, demystified. Dynamic programming solves a problem by combining answers to overlapping subproblems, stored so each is computed once. Start with 1-D recurrences (stairs, robbery, coins), move to 2-D grids and strings (paths, edit distance), then knapsack. The final chapter is a mixed gauntlet, your mock interview.