Arrays and lists
3 lessons
Searching and sorting
7 lessons- Linear search: one item at a timeWhy a hit at index k costs k + 1 probes and a miss costs all n, why stopping at the match still averages O(n), and when a plain scan beats sorting for binary search.Searching & sorting15 min
- Binary search: halve it until you find itWhy one comparison can rule out half of a sorted array, and how to never get the boundaries wrong.Searching & sorting15 min
- Heap sort: build a heap, then empty it from the backWhy building a max-heap in place costs only O(n), why swapping its root to the end and sifting down n − 1 times sorts any input in O(n log n) with O(1) extra memory, and why it still isn't stable and usually loses to quick sort.Searching & sorting15 min
- Bubble sort in code: read it, run it, change itPredict what real code does, run it to check, then change it and write a sort of your own, in Python, JavaScript or TypeScript.Searching & sorting25 min
- Merge sort: two sorted halves make a sorted wholeWhy merging two sorted halves takes one comparison per value, why that makes merge sort O(n log n) on every input, and what its buffer and its tie rule buy.Searching & sorting15 min
- Quick sort: place the pivot, then sort each sideWhy a partition puts its pivot in its final place for m − 1 comparisons, why that makes quick sort O(n log n) on average but O(n²) when every pivot is the largest value left, and what sorting in place still costs.Searching & sorting15 min
- Sorting without comparisons: count instead of compareWhy no comparison sort can beat about n log₂ n comparisons, how counting sort places small whole-number keys in O(n + k) with counts and running totals, why placing from the right keeps it stable, and how radix sort runs it once per digit.Searching & sorting15 min
Trees and heaps
6 lessons- Binary search trees: one path downSmaller keys to the left and larger to the right at every node: why search and insert cost one comparison per level, why sorted inserts make a slow chain, and how to delete a node with two children.Trees & heaps20 min
- Self-balancing trees: lift the taller sideKeep every node's two sides within one level of each other: how an AVL tree finds a node at ±2 on the way back up, how one or two rotations fix it without breaking the order, and why sorted keys no longer make a chain.Trees & heaps15 min
- B-trees: wide nodes, grown from the topWhy packing many sorted keys into each node keeps a tree a few levels tall, how a full node splits and sends its median up so the tree grows only at the root, and how a delete borrows through the parent or merges to keep every leaf on one level.Trees & heaps15 min
- Tries: one letter per edgeWhy a trie spells each word along a path from the root, why insert, search and starts-with take one step per letter however many words are stored, why a path is not a word without its end mark, and what all those nodes cost in memory.Trees & heaps15 min
- Heaps and priority queues: the most urgent firstA complete tree packed into an array: why the top is always one read away, why insert and remove take O(log n), and why a heap is not sorted.Trees & heaps20 min
- Union-find: same root, same groupDisjoint sets as trees in one parent array: why two elements share a set exactly when they reach the same root, why union links roots and never elements, and how union by rank and path compression make each operation nearly constant, amortised.Trees & heaps15 min
Problem-solving patterns
4 lessons- Two pointers: from n² pairs to n stepsUse the order of a sorted array to rule out a value with every comparison.Patterns12 min
- Sliding window: add one, drop oneUpdate one running total as the window slides instead of re-adding it, and grow and shrink a window to find the best run under a rule, both in O(n).Patterns15 min
- Intervals: sort by start, then look back onceSort by start, then sweep once: why a merge only has to check the last merged interval and must keep the larger end, why touching ends are each problem's choice, and how a min-heap of end times finds the fewest meeting rooms, the most meetings running at once, in O(n log n).Patterns15 min
- Monotonic stacks: pop what the new value beatsFind every value's next greater value in one pass: why the positions waiting on the stack never rise from bottom to top, why a loop inside a loop is still O(n) when each position is pushed once and popped at most once, and why the stack keeps indices rather than values.Patterns15 min
Graphs
7 lessons- Representing graphs: a list per vertex or a cell per pairAdjacency lists or an adjacency matrix: why one lists a vertex's neighbours in deg(u) steps and the other checks an edge in one read, why an undirected edge is stored twice, and which suits a sparse graph.Graphs15 min
- Breadth-first and depth-first search: a queue or a stackVisit everything a start can reach with a queue or a stack: why BFS's levels are the fewest edges, why DFS finds cycles but not shortest paths, and why marking a node when it is found keeps both O(V + E).Graphs15 min
- Topological sort: every prerequisite firstList tasks so every edge points forward: how Kahn's algorithm places a node once its last prerequisite is placed, in O(V + E), why running out of ready nodes proves a cycle, why many orders are often valid, and why depth-first search must reverse its finishing order.Graphs15 min
- Strongly connected components: two searches, the second backwardsGroups of nodes that all reach each other: why the node a depth-first search finishes last lies in a source component, why Kosaraju's second search runs on the reversed graph, how Tarjan's low-links find the same groups in one pass, and why squashing them leaves a DAG.Graphs15 min
- Dijkstra's algorithm: settle the closest node firstShortest paths by greedily settling nodes in order of distance, and the one assumption that makes it work.Graphs20 min
- All-pairs shortest paths: one more stop-over each roundFloyd–Warshall as dynamic programming over which nodes a route may stop at: why k must be the outer loop, why one matrix overwritten in place is enough, how a negative cycle shows on the diagonal, and when Dijkstra from every node is cheaper than Θ(V³).Graphs15 min
- Minimum spanning trees: the cheapest safe edgeConnecting every node at the least total cost: why the lightest edge across any split is always safe, how Kruskal's merges components with union-find and Prim's grows one tree with a heap, and why the result is not a map of shortest routes.Graphs15 min
Algorithm design
5 lessons- Memoization: stop solving the same problem twiceSee plain recursion explode, then tame it with a table of answers you have already found.Algorithm design15 min
- Dynamic programming: fill a table from the bottom upFour decisions turn a problem into a table you fill in a loop: what a cell means, how it is built, where it starts, and an order that keeps every input ready.Algorithm design20 min
- Dynamic programming on sequences: one prefix at a timeHow a table over prefixes finds the longest common subsequence and the edit distance of two words in O(mn), why listing the letters or edits needs the whole table, and how the longest increasing subsequence works on one sequence in O(n²) or, with binary search, O(n log n).Algorithm design15 min
- Backtracking: choose, explore, un-chooseMake one choice, explore everything after it, then undo it: why subsets give 2ⁿ leaves and orderings n!, why every choice must be undone and every answer copied, and how pruning cuts N-Queens and Sudoku down without beating the exponential worst case.Algorithm design15 min
- Greedy algorithms: take the best now, never look backWhy a sort and one pass of best-looking choices can be optimal: how an exchange argument proves that earliest finish first fits the most activities and best value per kilo first packs goods that can be cut, why shortest first and whole items break, and why the sort is usually the cost.Algorithm design15 min
Math for CS and ML
9 lessons- Matrices move spaceRead a matrix by its columns: where î and ĵ land decides where every vector goes, and the determinant scales area.Math15 min
- Eigenvectors: the directions a matrix only stretchesSweep a vector around the circle to find where A·v lines up with v, and see why rotations have none.Math15 min
- Derivatives and gradients: shrink the gapShrink the gap between two points until the secant becomes the tangent, estimate slopes in code without losing digits to rounding, and see why the gradient points uphill straight across the contour lines.Math15 min
- Bayes' rule: a 90% test that is usually wrongDraw everyone as a square to see why the prior matters as much as the evidence, and how to update twice.Math15 min
- The central limit theorem: why averages make bellsAverage samples from lopsided or two-humped populations and watch a bell appear, with a spread of σ/√n.Math12 min
- Entropy and KL divergence: information in bitsMeasure surprise in bits, then see what believing the wrong distribution costs, the loss every classifier minimises.Math15 min
- Backpropagation: the chain rule on a graphWatch gradients flow back through a computation graph, then write the engine yourself, micrograd style.Math30 min
- SVD: a picture as a sum of simple piecesRebuild pictures one rank-1 piece at a time, and see why a few pieces carry most of an image but none of the noise.Math15 min
- Floating point: why 0.1 + 0.2 isn’t 0.3Read a float32 bit by bit: sign, exponent and fraction, the gaps between floats, and why == is a trap.Math15 min
Machine learning
12 lessons- Gradient descent: how models learnFrom the slope at a point to walking downhill on a loss surface, and why the step size matters so much.Machine learning20 min
- Momentum and Adam: gradient descent with a memoryRace four optimisers through a narrow valley to see how remembering past gradients speeds up the floor, damps the zigzag and evens out the steps.Machine learning15 min
- Linear regression: shrink the squaresA model, a loss and gradient descent: fit a line by shrinking squared residuals you can see, and drag the data.Machine learning15 min
- Neural networks: why one neuron isn’t enoughSee a single neuron fail on XOR, then watch hidden units bend the boundary as the network trains.Machine learning20 min
- Logistic regression: a line that gives probabilitiesA sigmoid neuron trained on cross-entropy: watch the boundary swing into place, then fail honestly on XOR.Machine learning15 min
- k-means: find groups nobody labelledAssign points, move centres, repeat: why k-means always stops, and why it can stop in the wrong place.Machine learning12 min
- Decision trees and boosting: twenty questions, then many small fixesGrow a tree by Gini splits, watch it overfit, then add up small trees fitted to the residuals.Machine learning20 min
- Convolution: how networks see edgesSlide a 3×3 kernel over a picture to find its edges, then see what ReLU and max-pooling keep, and why the same 9 weights work everywhere.Machine learning15 min
- Attention: every token looks at every otherQueries, keys and values: score with dot products, softmax into weights, blend the values, mask the future, and cache keys while generating.Machine learning20 min
- How a language model writesLearn tokens with byte-pair encoding, turn logits into one next word with temperature, top-k and top-p, and see why generation caches keys and values.Machine learning20 min
- Reinforcement learning: learning from rewardsWatch an agent learn a gridworld from rewards alone: Q-values, the discount, and why exploring matters.Machine learning20 min
- Diffusion: generating by removing noiseNoise a shape away into a blob, then watch a trained denoiser turn fresh noise back into it, one small step at a time.Machine learning15 min
Systems
11 lessons- CPU scheduling: who runs next?One CPU, many processes: first come first served, shortest job first, round robin and priorities, and the waiting each one causes.Systems15 min
- Caching: LRU, LFU and page replacementWhy hit rate decides speed, how an LRU cache evicts in O(1), and what FIFO, LRU, Clock and OPT do with pages of memory.Systems20 min
- Consistent hashingSpread a cache over servers so that adding or removing one moves only about 1/N of the keys, with a hash ring and virtual nodes.Systems15 min
- Queueing and tail latencyWhy a busy server is slow long before it is full, why p99 matters more than the average, and how a token bucket keeps traffic in check.Systems20 min
- Rate limiting: one token per requestTwo numbers per client: why a token bucket lets a burst of up to its capacity through but never more than capacity + rate × t in any t seconds, why a fixed window can pass twice its limit, and how to hold a limit across many servers and retry with backoff and jitter.Systems15 min
- Race conditions, locks and deadlockHow two threads running count++ lose an update, how locks and atomic instructions fix it, and how locks taken in different orders deadlock.Systems20 min
- Storage engines: B+ trees and LSM treesThe two ways databases keep data on disk: a B+ tree finds any key in a few page reads and scans ranges along its leaves; an LSM tree turns writes into appends and merges them later.Systems20 min
- Logical clocks: ordering without a shared clockLamport timestamps give every event a number that respects cause and effect; vector clocks also tell you when two events are concurrent.Systems15 min
- Back-of-the-envelope estimationFrom daily users to requests a second, storage a year and bandwidth, with the latency numbers every engineer should know, rounded to powers of ten.Systems20 min
- System design: the core trade-offsBuild a service up on the simulator: a cache and what it costs in staleness, replicas and lag, sharding keys, queues for slow writes, and what happens when a machine dies.Systems30 min
- Consensus with RaftHow a cluster of servers agrees on one log while machines crash and the network splits: terms, elections, replication and the majority rule that keeps committed entries safe.Systems25 min