One topic at a time, until the algorithms actually stick.
Each topic is a group of related algorithms. Every lesson has the same shape: the concept, the steps, a demo you can press through yourself, the code, and problems to practise on.
Data structures
7 topics · 29 lessonsHow to judge whether an algorithm is any good. The vocabulary the rest of the site uses.
Used for:Why it was fast in testing and times out in production, Why pushing to a dynamic array counts as O(1), Handing the problem to a smaller version of yourself
The two most basic containers: reach things by position, or by key.
Used for:Caches and sessions, "How many times does this letter appear?", Range totals in a report, Images and game boards
Nodes strung together by pointers. O(1) insert and delete, but no jumping straight to an index.
Used for:Back and forward in a browser, LRU caches, Detecting a cycle
Order is itself information.
Used for:Bracket matching and undo in an editor, Print spoolers and message queues, "When is the next day the price is higher?", Window maximum on a dashboard
Get at the maximum or minimum whenever you want, for O(log n).
Used for:OS process scheduling, Top 10 most-read articles, A running median
Hierarchy without cycles. Recursion feels most natural here.
Used for:File systems and the DOM, Database indexes and sorted sets, Autocomplete in a search box, Live rankings and range statistics
How to store a graph in code, and how to answer "are these two connected?" quickly.
Used for:Friendships in a social network, Is the network still connected?, Grouping faces in a photo library
Algorithms
10 topics · 64 lessonsPutting things in order. From O(n²) to O(n log n), and where the comparison barrier sits.
Used for:Storefronts and leaderboards, ORDER BY and external sorting, Sorting as a prerequisite, When the values are plain integers
Finding things. Order lets you throw away half the data at every step.
Used for:git bisect finding the broken commit, "How fast do we have to go to make it?", "Average over the last 5 minutes", Two numbers summing to a target
Try every possibility, but turn back the moment it cannot work.
Used for:Timetabling and seating, Enumerating combinations, Sudoku and crosswords
Cut it into pieces, solve each, then put the answers back together.
Used for:Why halving makes it faster, Cryptography and big numbers, "How many pairs are out of order?"
Always take the best option available right now. When does that give the best overall answer?
Used for:Meeting rooms and timetables, Compression in zip and JPEG, Making change and OS scheduling, Can you reach the end?
Start with traversal, then shortest paths, dependency order and connectivity.
Used for:Map navigation, "People you may know", Install and build order, Laying network cable
Break a big problem into overlapping smaller ones, and remember the answers so you never recompute.
Used for:Spell check and autocorrect, git diff, Budgets and resource allocation, Why plain recursion is not enough
Matching, searching and hashing. The prefix function is the key tool here.
Used for:Ctrl+F and grep, Plagiarism and duplicate detection, DNA sequence analysis, Matching thousands of keywords at once
Work on the ones and zeroes directly. Fast, compact, and a way to represent sets.
Used for:Permissions and feature flags, Finding the one that is alone, Netmasks and hashing
The handful of mathematical tools that algorithm problems keep reaching for.
Used for:RSA behind HTTPS, Aspect ratios and reducing fractions, "How many ways are there?"