Vibe Engines
YouTube
DATA STRUCTURES & ALGORITHMS · PLAYED, NOT WATCHED

The algorithms course you play.

A full data-structures-and-algorithms curriculum rebuilt as playable games — 99 lessons on 26 ordered ladders. You drive each problem and lose to your own instincts, then meet the algorithm that never does. The pseudocode, complexity, a worked trace and a quiz come after, once it's already clicked. 29 rungs are marked Core: the spine to play first if you are preparing for an interview.

99Playable lessons
26Ladders
29On the core spine
100%Free · no sign-up
Your progress0 / 99 played
Start hereThe VaultDon't memorize binary search — play it. It is rung 1 of the core spine and of "Throw away half the answers" — the first idea in the subject, and the one every ladder below quietly assumes.Play it →
99 lessons

The moves

The handful of techniques that turn an O(n²) loop into an O(n) one, the four containers everything else is built from, and the sorts underneath half of all algorithms.

Throw away half the answers

The first idea in the subject: if the space is ordered, you never have to look at most of it.

0 / 2 played
  1. Binary SearchThe VaultCore Start here Don't memorize binary search — play it.BeginnerO(log n) · 3 acts
  2. Find the Peak by ThirdsTernary SearchDon't memorize ternary search — watch the window shrink.IntermediateO(log n) · 3 acts

Two pointers and a window

Four ways to make one pass do the work of two nested loops — then the stack that remembers which earlier element still matters.

0 / 5 played
  1. The Closing GapTwo PointersCore Start here Don't memorize the two-pointer trick — watch the gap close.BeginnerO(n) · 3 acts
  2. The Dutch National FlagThree-Way PartitionCoreDon't memorize sort-colors — watch three pointers sort it.IntermediateO(n) · 3 acts
  3. The Moving FrameSliding WindowCoreDon't memorize the sliding window — watch it glide.BeginnerO(n) · 3 acts
  4. The Running TotalPrefix SumsCoreDon't memorize prefix sums — watch the running total build.BeginnerO(1) query · 3 acts
  5. The Waiting LineMonotonic StackCoreDon't memorize the monotonic stack — watch it resolve.IntermediateO(n) · 3 acts

One pass, constant space

Three algorithms that see each element exactly once and keep almost nothing — including one that samples a stream whose length it does not know.

0 / 3 played
  1. The Last One StandingBoyer-Moore Majority VoteCore Start here Don't memorize the majority vote — watch the votes cancel out.IntermediateO(n) · 3 acts
  2. Fisher–YatesThe Fair ShuffleDon't memorize the Fisher–Yates shuffle — play it.BeginnerO(n) · 3 acts
  3. The Fair DrawReservoir SamplingCoreDon't memorize reservoir sampling — watch it stay fair.IntermediateO(n) · 3 acts

The four containers

Sequence, discipline, lookup, priority. Every structure further down this page is one of these four with a better answer to one question.

0 / 4 played
  1. The Chain of NodesLinked List Start here Don't memorize the linked list — watch the pointers move.BeginnerO(n) · 3 acts
  2. LIFO & FIFOStack & QueueCoreDon't memorize stacks and queues — watch them fill and drain side by side.BeginnerO(1) · 3 acts
  3. The Instant LookupHash TableCoreDon't memorize the hash table — watch it drop keys into buckets.BeginnerO(1) avg · 3 acts
  4. Sift Up, Sift DownHeap & Priority QueueCoreDon't memorize the heap — watch values sift up and down.IntermediateO(log n) · 3 acts

The comparison sorts

Divide, partition, heapify — three routes to n log n, then the hybrid your language actually ships.

0 / 4 played
  1. Merge SortThe CascadeCore Start here Don't read about merge sort — play it.IntermediateO(n log n) · 3 acts
  2. QuicksortThe Pivot PitCoreSee quicksort actually work — then drive it.IntermediateO(n log n) · 3 acts
  3. The TournamentHeap SortDon't memorize heap sort — watch the tournament play out.IntermediateO(n log n) · 3 acts
  4. TimsortSort What's Already ThereDon't memorize Timsort — play it.IntermediateO(n log n) · 4 acts

Beating n log n

Stop comparing and start counting. Three linear sorts that need to know something about the keys — and the one for data that does not fit in memory.

0 / 4 played
  1. No ComparisonsCounting & Radix Sort Start here Don't memorize counting sort — watch it sort without a single comparison.IntermediateO(n + k) · 3 acts
  2. Scatter, Sort, GatherBucket SortDon't memorize bucket sort — watch values fall into place.IntermediateO(n + k) avg · 3 acts
  3. Radix SortSorting Without ComparingDon't memorize radix sort — play it.IntermediateO(n · d) · 3 acts
  4. External Merge SortBigger Than MemoryDon't memorize external merge sort — play it.IntermediateO(n log n) · 4 acts

Nearly sorting

Two problems that look like sorting and are cheaper than it: find the k-th element without ordering the rest, and fix a permutation in place.

0 / 2 played
  1. Find the Kth ElementQuickselectCore Start here Don't memorize quickselect — watch it throw away half the array each step.IntermediateO(n) avg · 3 acts
  2. Every Number HomeCyclic SortCoreDon't memorize cyclic sort — watch each number walk home.IntermediateO(n) · 3 acts

Structures worth building

What you reach for when an array stops being enough — balanced trees, range queries, the on-disk shapes a database actually uses, and the sketches that trade exactness for memory.

Keeping a tree balanced

The unbalanced version first, so the next four read as answers to the same failure — rotate on insert, colour the nodes, randomise the priorities, or move what was just used to the top.

0 / 5 played
  1. The Ordered TreeBinary Search TreeCore Start here Don't memorize the BST — watch it grow.IntermediateO(log n) · 3 acts
  2. The Tree That Rebalances ItselfAVL TreeDon't memorize AVL rotations — watch the tree rebalance itself.AdvancedO(log n) · 3 acts
  3. Red-Black TreeBalance in Two ColorsDon't memorize the red-black tree — play it.AdvancedO(log n) · 4 acts
  4. TreapBalance by ChanceDon't memorize the treap — play it.AdvancedO(log n) expected · 4 acts
  5. Splay TreeTouch It, Lift ItDon't memorize the splay tree — play it.AdvancedO(log n) amortized · 4 acts

Walking a tree cleverly

Traverse it without a stack, then answer "what is the lowest common ancestor?" in logarithmic time.

0 / 2 played
  1. Morris TraversalThreading the Tree Start here Don't memorize Morris traversal — play it.AdvancedO(n) · 3 acts
  2. Two Nodes, Climbing to MeetLCA with Binary LiftingCoreDon't memorize binary lifting — watch two tree nodes climb to meet.AdvancedO(log n) query · 3 acts

Answering a range in log time

Blocks first, because it is the only one whose idea fits in a sentence — every structure above it is an answer to "what if the blocks were a tree?".

0 / 7 played
  1. Sqrt DecompositionBlocks of Root-N Start here Don't memorize sqrt decomposition — play it.IntermediateO(√n) · 4 acts
  2. Bits Do the WalkingFenwick TreeDon't memorize the binary indexed tree — watch the bits do the walking.AdvancedO(log n) · 3 acts
  3. The Segment TreeDon't memorize the segment tree — watch it answer ranges in log time.AdvancedO(log n) · 3 acts
  4. Lazy Segment TreeUpdate LazilyDon't memorize lazy propagation — play it.AdvancedO(log n) · 4 acts
  5. Persistent Segment TreeEvery Version KeptDon't memorize the persistent segment tree — play it.AdvancedO(log n) / update · 4 acts
  6. Interval TreeWhat Contains This?Don't memorize the interval tree — play it.AdvancedO(log n + k) · 4 acts
  7. Mo's AlgorithmReorder to WinDon't memorize Mo's algorithm — play it.AdvancedO((n+q)·√n) · 4 acts

Structures a database ships

What changes when the structure lives on a disk, is written by a thousand machines at once, or has to survive an editor undoing your last keystroke.

0 / 5 played
  1. How Databases Stay BalancedB-TreesCore Start here Don't memorize B-trees — watch a node overflow and split.IntermediateO(log n) · 4 acts
  2. LSM-TreeWrite Fast, Merge LaterDon't memorize the LSM-tree — play it.AdvancedO(1) write amort. · 4 acts
  3. Express LanesThe Skip ListCoreDon't memorize the skip list — ride its express lanes.AdvancedO(log n) exp. · 3 acts
  4. Piece Table & RopeEdit Without CopyingDon't memorize the piece table — play it.IntermediateO(1) insert* · 4 acts
  5. Consistent HashingThe RingDon't memorize consistent hashing — play the ring.IntermediateO(log N) · 4 acts

Trading exactness for memory

Four structures that answer a question wrongly on purpose, with a bound on how wrong — and are the only practical answer at a billion items.

0 / 4 played
  1. Bloom FilterMaybe Yes, Never No Start here Don't memorize the Bloom filter — play it.IntermediateO(k) · 3 acts
  2. Count–Min SketchCounting in Tiny SpaceDon't memorize the Count–Min Sketch — play it.AdvancedO(d) · 3 acts
  3. Counting a Crowd in KilobytesHyperLogLogCoreDon't memorize HyperLogLog — watch leading zeros count a crowd.AdvancedO(1) add · 3 acts
  4. MinHashSimilarity in a SignatureDon't memorize MinHash — play it.AdvancedO(k · n) · 4 acts

Graphs

The universal model. Walk it, find the cheapest way across it, work out what it is connected to, then push as much through it as it will take.

Walking a graph

Breadth then depth — the two orders everything else in this arc is built on — then two walks with a twist.

0 / 4 played
  1. BFSThe FloodCore Start here Don't memorize breadth-first search — play it.BeginnerO(V + E) · 3 acts
  2. Build OrderDFS & Topological SortCoreDon't memorize topological sort — play it.IntermediateO(V + E) · 3 acts
  3. Bidirectional BFSMeet in the MiddleDon't memorize bidirectional BFS — play it.IntermediateO(b^(d/2)) · 3 acts
  4. Eulerian PathEvery Edge, OnceDon't memorize Hierholzer's algorithm — play it.IntermediateO(E) · 4 acts

The cheapest way across

Dijkstra first, then the three algorithms that exist because of something Dijkstra cannot do: use a hint, survive a negative edge, or answer every pair at once.

0 / 4 played
  1. DijkstraThe Last MileCore Start here Don't watch Dijkstra's algorithm — play it.BeginnerO(E log V) · 4 acts
  2. A* SearchThe AscentDon't memorize A* — fly it.IntermediateO(E log V) · 4 acts
  3. The Patient RouterBellman-FordDon't memorize Bellman-Ford — watch the distances settle.AdvancedO(V·E) · 3 acts
  4. Every Vertex a Stepping StoneFloyd–WarshallDon't memorize Floyd–Warshall — watch the distance matrix improve.AdvancedO(V³) · 3 acts

What is connected to what

The structure that answers it in almost constant time, the two spanning trees built on top of it, and then the parts of a graph whose removal breaks it.

0 / 5 played
  1. Six DegreesUnion-Find Start here Don't memorize the Disjoint Set Union — play it.IntermediateO(α(n)) · 3 acts
  2. The Cheapest GridKruskal's MSTDon't memorize Kruskal's algorithm — watch it wire up a network.IntermediateO(E log E) · 3 acts
  3. Grow the Cheapest TreePrim’s MSTDon't memorize Prim's algorithm — watch the tree grow.IntermediateO((V+E) log V) · 3 acts
  4. Cycles Into ComponentsTarjan’s SCCCoreDon't memorize Tarjan's algorithm — watch cycles collapse into components.AdvancedO(V + E) · 4 acts
  5. Bridges & Articulation PointsThe Weak LinksDon't memorize Tarjan's bridge-finding — play it.AdvancedO(V + E) · 4 acts

Pushing as much as it will take

Max flow, then the same problem with a price on each edge, then the assignment problem that turns out to be the same thing again.

0 / 3 played
  1. Pushing Water Through PipesDinic’s Max-FlowCore Start here Don't memorize Dinic's algorithm — watch flow saturate a network.AdvancedO(V²E) · 4 acts
  2. Min-Cost Max-FlowCheapest Flow FirstDon't memorize min-cost max-flow — play it.AdvancedO(V·E·f) · 4 acts
  3. Hungarian AlgorithmThe Perfect MatchDon't memorize the Hungarian algorithm — play it.AdvancedO(n³) · 4 acts

Searching a space

Three answers to the same question — never solve a subproblem twice, take the locally best choice when that is provably enough, or try everything and undo.

DP along one axis

The four that teach the whole idea: a running best, a count, a capacity, and a length. Play them in this order and the recurrence stops being a trick.

0 / 4 played
  1. The Best StreakKadane's AlgorithmCore Start here Don't memorize Kadane's algorithm — watch the best streak emerge.IntermediateO(n) · 3 acts
  2. The Fewest CoinsCoin ChangeCoreDon't memorize coin change — watch the table fill.IntermediateO(n·A) · 3 acts
  3. The Loaded Bag0/1 KnapsackCoreDon't memorize the knapsack DP — watch the table fill.IntermediateO(n·W) · 3 acts
  4. The Longest ClimbLongest Increasing SubsequenceDon't memorize the LIS — watch it build.IntermediateO(n²) · 3 acts

DP across two sequences

The same grid twice — once counting what matches, once counting what it costs to fix what does not.

0 / 2 played
  1. Fill the Grid, Walk It BackLongest Common Subsequence Start here Don't memorize LCS — watch the table fill, then walk it backwards.IntermediateO(n·m) · 3 acts
  2. The Typo FixerEdit DistanceDon't memorize edit distance — watch the grid fill in.IntermediateO(m·n) · 3 acts

When the state is not a number

What to do when the thing you index by is a subtree, a subset, or a digit position — and when to give up on DP and split the search in half.

0 / 4 played
  1. Tree DPAnswers Flow Up Start here Don't memorize tree DP — play it.IntermediateO(n) · 4 acts
  2. Bitmask DPSets as IntegersDon't memorize bitmask DP — play it.AdvancedO(2ⁿ·n²) · 4 acts
  3. Digit DPCount by DigitsDon't memorize digit DP — play it.AdvancedO(digits × states) · 4 acts
  4. Halving the ExponentialMeet in the MiddleDon't memorize meet-in-the-middle — watch two halves shake hands.AdvancedO(2^(n/2)) · 3 acts

When greedy is provably enough

Two problems where the locally best choice is optimal, and then the lesson that tells you how to know which is which.

0 / 3 played
  1. Finish First, Fit the MostInterval Scheduling Start here Don't memorize activity selection — watch the greedy choice pay off.IntermediateO(n log n) · 3 acts
  2. Frequent Symbols, Short CodesHuffman CodingDon't memorize Huffman coding — watch the tree assemble itself.IntermediateO(n log n) · 3 acts
  3. Greedy vs Dynamic ProgrammingWhen Is Greedy Safe?Don't guess which technique a problem needs — play both.Intermediategreedy O(n log n) / DP O(n·W) · 3 acts

Try, fail, undo

Enumerate everything, then add a constraint, then add a hard one — the same recursion each time, pruned harder.

0 / 4 played
  1. Push, Recurse, PopSubsets by Backtracking Start here Don't memorize backtracking — watch the decision tree grow and unwind.IntermediateO(n · 2ⁿ) · 3 acts
  2. Cut the Dead BranchesCombination SumDon't memorize combination sum — watch the dead branches get cut.IntermediateO(n^(T/min)) · 3 acts
  3. The StandoffN-QueensCoreDon't memorize backtracking — watch it try, clash, and undo.IntermediateO(n!) · 3 acts
  4. Guess, Hit a Wall, EraseSudoku SolverDon't memorize the Sudoku solver — watch it guess, hit a wall and erase.AdvancedO(k^m) · 3 acts

Text

Match a pattern without re-reading a character, then index the text so you never scan it again.

Matching without backing up

Hash it, then the three algorithms that never re-read a character — and finally the one that matches a thousand patterns in the same pass.

0 / 5 played
  1. The Rolling HashRabin-Karp Start here Don't memorize Rabin-Karp — watch the hash roll.IntermediateO(n + m) · 3 acts
  2. The Non-BacktrackerKMPDon't memorize KMP — watch the pattern slide.AdvancedO(n + m) · 3 acts
  3. Slide the Z-BoxZ-AlgorithmDon't memorize the Z-algorithm — watch the Z-box slide.AdvancedO(n + m) · 3 acts
  4. Let the Mirror Do the WorkManacher’s AlgorithmDon't memorize Manacher's algorithm — watch the mirror do the work.AdvancedO(n) · 3 acts
  5. One Pass, Every WordAho-CorasickDon't memorize Aho-Corasick — watch one pass catch every pattern.AdvancedO(n + z) · 4 acts

Indexing the text instead

Pay once to build the index, then stop scanning the text at all.

0 / 2 played
  1. The Word TreeTrie Start here Don't memorize the trie — watch words grow into a tree.IntermediateO(L) · 3 acts
  2. Suffix ArraySuffixes, SortedDon't memorize the suffix array — play it.AdvancedO(n log n) · 4 acts

Numbers and geometry

The classics that keep turning up in cryptography, in compilers and in the one interview question nobody prepares for.

Number theory, in order

GCD, then what it also gives you, then the exponentiation every crypto library runs — then finding primes, testing them, and finally factoring one.

0 / 6 played
  1. The Biggest Tile That FitsEuclidean GCD Start here Don't memorize the Euclidean algorithm — see it as tiling.BeginnerO(log min(a,b)) · 3 acts
  2. Extended Euclidean & CRTgcd, and a BonusDon't memorize the extended Euclidean algorithm — play it.AdvancedO(log min(a,b)) · 4 acts
  3. Climb in Doubling JumpsModular ExponentiationDon't memorize fast power — watch the exponent climb in doubling jumps.IntermediateO(log b) · 3 acts
  4. Sieve of EratosthenesPrime TimeFind every prime under 100 without dividing once.BeginnerO(n log log n) · 1 act
  5. Miller–RabinProbably PrimeDon't memorize Miller–Rabin — play it.AdvancedO(k · log³ n) · 4 acts
  6. Pollard's RhoFactor by CollisionDon't memorize Pollard's rho — play it.AdvancedO(n^¼) expected · 4 acts

Multiplying faster than school

Three divide-and-conquer results that beat the obvious quadratic — on integers, on signals, and on a recurrence you thought needed a loop.

0 / 3 played
  1. KaratsubaThree, Not Four Start here Don't memorize Karatsuba — play it.IntermediateO(n^1.585) · 3 acts
  2. FFTValues, Not CoefficientsDon't memorize the FFT — play it.AdvancedO(n log n) · 4 acts
  3. Fibonacci Fast-ForwardedMatrix ExponentiationDon't memorize matrix exponentiation — watch it fast-forward.AdvancedO(log n) · 3 acts

Two sweeps over geometry, and then the algorithm for when the space is too ugly for any of the above.

0 / 3 played
  1. Convex HullWrapping the Points Start here Don't memorize the convex hull — play it.IntermediateO(n log n) · 3 acts
  2. Line SweepSliding the LineDon't memorize the line sweep — play it.IntermediateO(n log n) · 4 acts
  3. Simulated AnnealingCool to ImproveDon't memorize simulated annealing — play it.AdvancedO(iters) · 4 acts

How to use this hub

1

Play the lesson

Drive the algorithm yourself and lose — then watch it win. Intuition before formalism.

2

Read the theory

Pseudocode, complexity, a worked trace and a quiz — now that it has clicked.

3

Practice it

Solve the matching coding challenge in your browser, tests and all.

4

Keep it

Review the flashcards and the Big-O cheatsheet so it sticks for the interview.

The patterns underneath

Individual algorithms are worth learning, but the real prize is the handful of patterns they share — the moves that unlock unfamiliar problems in an interview.

Divide & Conquer

Split in half, solve, combine — binary search, merge sort, quicksort.

Two Pointers & Windows

Move indices instead of re-scanning — the sliding window.

BFS / DFS

Explore in rings or dive deep — every graph and tree traversal.

Dynamic Programming

Cache overlapping subproblems — edit distance, shortest paths.

Greedy

Take the locally best choice — Kruskal’s MST, Dijkstra.

Backtracking

Try, recurse, undo — N-Queens and constraint search.

Complexity reference

The Big-O you'll be asked to recite — data-structure operations and the sorting algorithms compared. The full version lives on the Big-O cheatsheet.

Data structure operations · average case

StructureAccessSearchInsertDelete
ArrayO(1)O(n)O(n)O(n)
Dynamic ArrayO(1)O(n)O(1)*O(n)
Hash Table—O(1)O(1)O(1)
Linked ListO(n)O(n)O(1)O(1)
Stack / QueueO(n)O(n)O(1)O(1)
Binary Search TreeO(log n)O(log n)O(log n)O(log n)
HeapO(1)†O(n)O(log n)O(log n)

* amortized · † peek the max/min

Sorting algorithms

AlgorithmBestAverageWorstSpaceStable
QuicksortO(n log n)O(n log n)O(n²)O(log n)No
Merge SortO(n log n)O(n log n)O(n log n)O(n)Yes
Heap SortO(n log n)O(n log n)O(n log n)O(1)No
Counting SortO(n + k)O(n + k)O(n + k)O(k)Yes

Learn it. Practice it. Keep it.

Data structures & algorithms — frequently asked questions

What is the best way to learn algorithms and data structures?

Build intuition before memorizing. Watching an animation or grinding LeetCode templates rarely sticks because it's passive — you remember what you've done, not what you've watched. Each lesson here is a playable game: you solve the problem yourself and fail, then see exactly why the algorithm wins, followed by the formal pseudocode, time and space complexity, a worked trace and a quiz. Feeling the problem first, then formalizing it, is what makes data structures and algorithms stick for interviews and real work.

Do these algorithm lessons help with coding interviews?

Yes. Data structures and algorithms (DSA) are half of every technical interview loop — system design is the other half, covered separately on the site. The lessons target the graph, shortest-path, sorting, search and dynamic-programming topics that come up most often, and they build the reasoning behind each algorithm so you can adapt under pressure instead of recalling a memorized template.

Which algorithm should I learn first?

Start with Dijkstra's shortest-path algorithm (The Last Mile). Graphs and shortest paths underpin pathfinding, network routing and a large share of interview questions, and the priority-queue idea at Dijkstra's core carries straight over to BFS, A*, and Prim's algorithm. From there, branch into sorting, binary search and dynamic programming as they're added.

Do I need to be good at math to learn algorithms?

No. These lessons lead with visual intuition and a concrete story, not proofs. You'll meet Big-O notation and see why each algorithm is correct, but the understanding comes from playing the problem — driving it, predicting its moves, and breaking it — not from heavy mathematics.

How is this different from a textbook, a video, or LeetCode?

You participate instead of watching. A textbook explains and a video shows; here you drive the algorithm, predict its next step, and even sabotage it to see where it breaks. That active recall, paired with the full theory (pseudocode, complexity, a worked trace and a quiz), builds far more durable understanding than passively reading or grinding problems before the concept has clicked.

Are the algorithm lessons free?

Yes — every lesson is completely free, runs entirely in your browser with no account or sign-up, and is keyboard-playable with a text version of each diagram for screen readers.