Topics
Pick something to watch.
Ready to play now
99 of 99 topics are live. More are on the way.
Foundations
Big-O complexity
PlayCount steps as the input grows
beginnerFoundations
Recursion
PlayWatch the call stack grow and unwind
beginnerFoundations
Stack vs heap memory
PlayWhere your variables actually live
beginnerArrays and strings
Array basics
PlayIndex, insert, delete, shift
beginnerO(1) accessArrays and strings
Dynamic array
PlayGrowing by doubling capacity
beginnerO(1) amortizedArrays and strings
2D arrays
PlayRows, columns, and memory layout
beginnerArrays and strings
Strings
PlayCharacters, immutability, builders
beginnerArrays and strings
Two pointers
PlayTwo indexes closing in on an answer
beginnerO(n)Arrays and strings
Sliding window
PlayA moving range over the array
intermediateO(n)Arrays and strings
Prefix sum
PlayRange sums in constant time
beginnerO(1) queryArrays and strings
Difference array
PlayRange updates in constant time
intermediateO(1) updateLinked lists
Singly linked list
PlayInsert, delete, reverse
beginnerO(n) searchLinked lists
Doubly linked list
PlayPointers in both directions
beginnerLinked lists
Circular linked list
PlayThe tail points back to the head
beginnerLinked lists
Skip list
PlayExpress lanes over a sorted list
advancedO(log n)Stacks and queues
Stack
PlayLast in, first out
beginnerO(1) push/popStacks and queues
Queue
PlayFirst in, first out
beginnerO(1)Stacks and queues
Circular queue
PlayWrap around a fixed buffer
beginnerStacks and queues
Deque
PlayPush and pop at both ends
intermediateStacks and queues
Priority queue
PlayAlways serve the most important
intermediateO(log n)Stacks and queues
Monotonic stack
PlayNext greater element in one pass
intermediateO(n)Stacks and queues
Monotonic queue
PlaySliding window maximum
advancedO(n)Hashing
Hash functions
PlayFrom a key to a bucket index
beginnerHashing
Separate chaining
PlayA list inside every bucket
intermediateO(1) avgHashing
Linear probing
PlayStep to the next free slot
intermediateHashing
Quadratic probing
PlayJump by squares to spread out
intermediateHashing
Double hashing
PlayA second hash picks the step
advancedHashing
Load factor and rehashing
PlayGrow the table when it fills up
intermediateHashing
LRU cache
PlayHash map plus a doubly linked list
intermediateO(1)Hashing
Bloom filter
PlayProbably yes, definitely no
advancedTrees
Binary tree basics
PlayRoot, leaves, height, depth
beginnerTrees
Tree traversals
PlayPre, in, post, and level order
beginnerO(n)Trees
Binary search tree
PlayInsert, search, delete
beginnerO(h)Trees
AVL tree
PlayRotations keep the tree balanced
intermediateO(log n)Trees
Red-black tree
PlayRecolor and rotate to stay balanced
advancedO(log n)Trees
Splay tree
PlayRecently used nodes move to the top
advancedTrees
Treap
PlayA BST with heap priorities
advancedTrees
B-tree
PlayMany keys per node, built for disks
advancedO(log n)Trees
B+ tree
PlayHow databases index rows
advancedTrees
Expression tree
PlayEvaluate math as a tree
intermediateTrees
Huffman coding
PlayShorter codes for common letters
intermediateO(n log n)Heaps
Binary heap
PlaySift up, sift down, heapify
intermediateO(log n)Heaps
d-ary heap
PlayMore children, shorter tree
advancedHeaps
Binomial heap
PlayA forest of binomial trees
advancedHeaps
Fibonacci heap
PlayLazy merges, fast decrease-key
advancedHeaps
Leftist heap
PlayMerge two heaps quickly
advancedRange queries
Segment tree
PlayRange sum, min, and max
intermediateO(log n)Range queries
Lazy propagation
PlayDelay range updates until needed
advancedRange queries
Fenwick tree
PlayPrefix sums with bit tricks
intermediateO(log n)Range queries
Sparse table
PlayConstant-time range minimum
advancedO(1) queryRange queries
Sqrt decomposition
PlaySplit the array into blocks
advancedO(√n)String structures
Trie
PlayAutocomplete, one letter per level
intermediateO(L)String structures
Radix tree
PlayA trie with merged chains
advancedString structures
Suffix array
PlayAll suffixes, sorted
advancedString structures
Suffix tree
PlayEvery substring in one tree
advancedString structures
Aho-Corasick
PlayFind many patterns at once
advancedGraphs
Graph representation
PlayAdjacency list vs matrix
beginnerGraphs
Breadth-first search
PlayExplore level by level
beginnerO(V + E)Graphs
Depth-first search
PlayGo deep, then backtrack
beginnerO(V + E)Graphs
Dijkstra's algorithm
PlayShortest paths, no negative edges
intermediateO(E log V)Graphs
Bellman-Ford
PlayShortest paths with negative edges
intermediateO(VE)Graphs
Floyd-Warshall
PlayShortest paths between all pairs
advancedO(V³)Graphs
A* search
PlayShortest path with a smart guess
advancedGraphs
Prim's MST
PlayGrow a tree from one node
intermediateO(E log V)Graphs
Kruskal's MST
PlayAdd the cheapest safe edge
intermediateO(E log E)Graphs
Topological sort
PlayOrder tasks by dependencies
intermediateO(V + E)Graphs
Union-find
PlayUnion by rank, path compression
intermediate≈ O(1)Graphs
Cycle detection
PlayFind loops in a graph
intermediateGraphs
Bipartite check
PlayColor the graph with two colors
intermediateGraphs
Strongly connected components
PlayKosaraju and Tarjan
advancedGraphs
Bridges and articulation points
PlayEdges and nodes that hold it together
advancedGraphs
Maximum flow
PlayPush flow through a network
advancedSorting
Bubble sort
PlayBig values bubble to the end
beginnerO(n²)Sorting
Selection sort
PlayPick the smallest, every pass
beginnerO(n²)Sorting
Insertion sort
PlayLike sorting cards in your hand
beginnerO(n²)Sorting
Merge sort
PlaySplit in half, merge back sorted
intermediateO(n log n)Sorting
Quick sort
PlayPartition around a pivot
intermediateO(n log n)Sorting
Heap sort
PlayBuild a heap, pop the max
intermediateO(n log n)Sorting
Counting sort
PlayCount each value, no comparisons
intermediateO(n + k)Sorting
Radix sort
PlaySort digit by digit
intermediateO(nk)Sorting
Bucket sort
PlayScatter into buckets, then gather
intermediateO(n + k)Sorting
Shell sort
PlayInsertion sort with shrinking gaps
advancedSorting
Tim sort
PlayWhat Python and Java really use
advancedO(n log n)Searching
Linear search
PlayCheck every item in turn
beginnerO(n)Searching
Binary search
PlayHalve the range every step
beginnerO(log n)Searching
Ternary search
PlayFind the peak of a curve
intermediateO(log n)Searching
Interpolation search
PlayGuess where the value should be
intermediateSearching
Exponential search
PlayDouble the range, then binary search
intermediateO(log n)Problem-solving techniques
Divide and conquer
PlaySplit, solve, combine
intermediateProblem-solving techniques
Greedy algorithms
PlayTake the best choice right now
intermediateProblem-solving techniques
Dynamic programming
PlayFill the table, reuse answers
intermediateProblem-solving techniques
Backtracking
PlayTry, fail, undo, try again
intermediateProblem-solving techniques
Bit manipulation
PlayTricks with ones and zeros
intermediateAdvanced structures
k-d tree
PlayNearest neighbor in space
advancedAdvanced structures
Quadtree
PlaySplit a map into four, again and again
advancedAdvanced structures
Interval tree
PlayWhich ranges overlap this one?
advancedAdvanced structures
Persistent structures
PlayKeep every old version
advancedAdvanced structures
Rope
PlayEdit huge strings fast
advancedAdvanced structures
Count-min sketch
PlayApproximate counts in tiny memory
advanced
Foundations
The ideas every other topic builds on.
Arrays and strings
Contiguous memory and the patterns that use it.
Array basics
PlayIndex, insert, delete, shift
beginnerO(1) accessDynamic array
PlayGrowing by doubling capacity
beginnerO(1) amortized2D arrays
PlayRows, columns, and memory layout
beginnerStrings
PlayCharacters, immutability, builders
beginnerTwo pointers
PlayTwo indexes closing in on an answer
beginnerO(n)Sliding window
PlayA moving range over the array
intermediateO(n)Prefix sum
PlayRange sums in constant time
beginnerO(1) queryDifference array
PlayRange updates in constant time
intermediateO(1) update
Linked lists
Nodes connected by pointers.
Stacks and queues
Ordered access from one end or both.
Stack
PlayLast in, first out
beginnerO(1) push/popQueue
PlayFirst in, first out
beginnerO(1)Circular queue
PlayWrap around a fixed buffer
beginnerDeque
PlayPush and pop at both ends
intermediatePriority queue
PlayAlways serve the most important
intermediateO(log n)Monotonic stack
PlayNext greater element in one pass
intermediateO(n)Monotonic queue
PlaySliding window maximum
advancedO(n)
Hashing
Turning keys into array positions.
Hash functions
PlayFrom a key to a bucket index
beginnerSeparate chaining
PlayA list inside every bucket
intermediateO(1) avgLinear probing
PlayStep to the next free slot
intermediateQuadratic probing
PlayJump by squares to spread out
intermediateDouble hashing
PlayA second hash picks the step
advancedLoad factor and rehashing
PlayGrow the table when it fills up
intermediateLRU cache
PlayHash map plus a doubly linked list
intermediateO(1)Bloom filter
PlayProbably yes, definitely no
advanced
Trees
Hierarchies, search trees, and balancing.
Binary tree basics
PlayRoot, leaves, height, depth
beginnerTree traversals
PlayPre, in, post, and level order
beginnerO(n)Binary search tree
PlayInsert, search, delete
beginnerO(h)AVL tree
PlayRotations keep the tree balanced
intermediateO(log n)Red-black tree
PlayRecolor and rotate to stay balanced
advancedO(log n)Splay tree
PlayRecently used nodes move to the top
advancedTreap
PlayA BST with heap priorities
advancedB-tree
PlayMany keys per node, built for disks
advancedO(log n)B+ tree
PlayHow databases index rows
advancedExpression tree
PlayEvaluate math as a tree
intermediateHuffman coding
PlayShorter codes for common letters
intermediateO(n log n)
Heaps
Trees that always know their minimum.
Range queries
Answer questions about any slice of an array fast.
Segment tree
PlayRange sum, min, and max
intermediateO(log n)Lazy propagation
PlayDelay range updates until needed
advancedFenwick tree
PlayPrefix sums with bit tricks
intermediateO(log n)Sparse table
PlayConstant-time range minimum
advancedO(1) querySqrt decomposition
PlaySplit the array into blocks
advancedO(√n)
String structures
Search and store text efficiently.
Graphs
Nodes, edges, paths, and networks.
Graph representation
PlayAdjacency list vs matrix
beginnerBreadth-first search
PlayExplore level by level
beginnerO(V + E)Depth-first search
PlayGo deep, then backtrack
beginnerO(V + E)Dijkstra's algorithm
PlayShortest paths, no negative edges
intermediateO(E log V)Bellman-Ford
PlayShortest paths with negative edges
intermediateO(VE)Floyd-Warshall
PlayShortest paths between all pairs
advancedO(V³)A* search
PlayShortest path with a smart guess
advancedPrim's MST
PlayGrow a tree from one node
intermediateO(E log V)Kruskal's MST
PlayAdd the cheapest safe edge
intermediateO(E log E)Topological sort
PlayOrder tasks by dependencies
intermediateO(V + E)Union-find
PlayUnion by rank, path compression
intermediate≈ O(1)Cycle detection
PlayFind loops in a graph
intermediateBipartite check
PlayColor the graph with two colors
intermediateStrongly connected components
PlayKosaraju and Tarjan
advancedBridges and articulation points
PlayEdges and nodes that hold it together
advancedMaximum flow
PlayPush flow through a network
advanced
Sorting
Put things in order, eleven different ways.
Bubble sort
PlayBig values bubble to the end
beginnerO(n²)Selection sort
PlayPick the smallest, every pass
beginnerO(n²)Insertion sort
PlayLike sorting cards in your hand
beginnerO(n²)Merge sort
PlaySplit in half, merge back sorted
intermediateO(n log n)Quick sort
PlayPartition around a pivot
intermediateO(n log n)Heap sort
PlayBuild a heap, pop the max
intermediateO(n log n)Counting sort
PlayCount each value, no comparisons
intermediateO(n + k)Radix sort
PlaySort digit by digit
intermediateO(nk)Bucket sort
PlayScatter into buckets, then gather
intermediateO(n + k)Shell sort
PlayInsertion sort with shrinking gaps
advancedTim sort
PlayWhat Python and Java really use
advancedO(n log n)
Searching
Find what you're looking for.
Linear search
PlayCheck every item in turn
beginnerO(n)Binary search
PlayHalve the range every step
beginnerO(log n)Ternary search
PlayFind the peak of a curve
intermediateO(log n)Interpolation search
PlayGuess where the value should be
intermediateExponential search
PlayDouble the range, then binary search
intermediateO(log n)
Problem-solving techniques
Strategies that combine the structures above.
Advanced structures
Specialized tools for space, time, and scale.
k-d tree
PlayNearest neighbor in space
advancedQuadtree
PlaySplit a map into four, again and again
advancedInterval tree
PlayWhich ranges overlap this one?
advancedPersistent structures
PlayKeep every old version
advancedRope
PlayEdit huge strings fast
advancedCount-min sketch
PlayApproximate counts in tiny memory
advanced