~/boss
Boss fights
Every boss is an algorithm. You beat it by doing it: tap, think, win. About a minute each, and they work on a phone. Each one has a Short on YouTube.
- Binary search The Sorted Golem Find its weak spot in as few hits as you can. Par is 10. Fight
- Floyd's cycle detection The Loop Demon Two heroes, no map. Find the room where the loop begins. Fight
- Boyer-Moore majority vote The Purple King Run the vote yourself. One mistake too many and the horde wins. Fight
- Memoization The Hydra Cut a head, two grow back. Slay head 10 in 11 cuts. Fight
- Topological sort (Kahn's algorithm) The Quest Board Play every quest in an order that works. Some boards are cursed. Fight
- Kadane's algorithm The Treasure Corridor One walk through gold and traps. Hold the richest bag you can. Fight
- Sliding window The Monster Parade Catch the longest run with no monster twice. Fight
- Breadth-first search The Maze You are the wave. Paint each step outward until you touch the exit. Fight
- Union-find The Eight Kingdoms Sign every treaty. Find each kingdom's king, and make one bow. Fight
- Two sum with a hash map The Potion Shelf Find the two potions that make 100. One walk down the shelf. Fight
- Hash map (buckets and chaining) The Monster Vault Store every monster in one step. Then fetch them back in one step. Fight
- Two pointers Two Knights, One Bridge One knight at each end of a sorted bridge. Find the pair with zero wasted steps. Fight
- Two pointers (trapping rain water) The Flood Rain falls on a row of pillars. Measure every drop that stays. Fight
- Multi-source BFS The Outbreak Every zombie bites at once. Paint each minute's bites, then call the answer. Fight
- Dynamic programming The Dragon Hoards Rob two neighbors and the alarm goes off. Take the most gold you can. Fight
- Dynamic programming (bottom-up) The Tower Climb 1 or 2 floors at a time. Count every way to the top. Fight
- Bloom filter The Name Guard Light each name's bits, then answer: is this name taken? Fight
- Two heaps (running median) The Middle Boss Monsters keep coming. Keep two heaps level and call the median every time. Fight
- Fast exponentiation The Power-Up Reach 2 to the million in 27 steps instead of a million. Fight
- 0/1 knapsack (dynamic programming) The Loot Limit Your bag holds 10 kg. Take or leave each treasure, cell by cell, and max the loot. Fight
- Backtracking The Cursed Grid Fill the cursed sudoku one square at a time. Hit a dead end? Erase and go back. Fight
- Stack (bracket matching) The Seal Read the seal one bracket at a time. Does it hold, or does it break? Fight
- Reversing a linked list The Chain Flip every monster's arrow in one pass, without losing anyone. Fight
- Invert a binary tree (recursion) The Mirror Flip the tree into its reflection. One swap per node, in the order the recursion calls them. Fight
- Consistent hashing The Server Ring Walk every key to its server. Then add a server and move almost nothing. Fight
- Sieve of Eratosthenes The Prime Hunt Only the primes are real bosses. Cross out the fakes and know when to stop. Fight
- Merge intervals The Waves The boss's attacks overlap. Sort them, then merge them into as few waves as you can. Fight
- One-pass max profit The Dragon Market Buy one scale, sell it on a later day. Find the best profit in one walk. Fight
- Huffman coding The Secret Scroll Shrink the scroll from 88 bits to 23. Join the two rarest, again and again. Fight
- Bit trick: n & (n − 1) The Bit Check Power of two or not? Subtract one, AND, and call it before the clock runs out. Fight
- Patience sorting (LIS) The Rising Chain Deal the monsters into piles like solitaire. The piles count the longest rising chain. Fight
- Dutch national flag (three pointers) The Color Chaos Red, white and blue monsters, all mixed up. Sort them in one pass. Fight
- Spiral order (four walls) The Spiral Vault Loot every cell in a spiral. Walk a wall, then move it in. Fight
- Token bucket rate limiter The Gatekeeper Guard the server gate. Read the bucket: let each request through, or reject it. Fight
- Binary search in a rotated sorted array The Twisted Doors Someone rotated the sorted doors. Find door 42 in log n steps. Fight
- Kruskal's algorithm (minimum spanning tree) The Road Builder Join every castle for the least stone. Cheapest road first, never a loop. Fight
- Greedy (farthest reach) The River Crossing Can you reach the last stone? Track one number and call it before you fall in. Fight
- Hash map (group anagrams) The Spell Sorter Same letters, same group. Sort the spell pile without comparing a single pair. Fight
- Two pointers (container with most water) The Reservoir Pick two pillars that hold the most water. Check 8 pairs, not 36. Fight
- Expand around center The Mirror Spell Each spell hides a palindrome. Pick its center, expand, and find the longest. Fight
- Monotonic stack The Heat Wave How long until a warmer day? Pop or push, one day at a time. Fight
- Bipartite check (two-coloring with BFS) The Clan War Split the monsters into two clans with no enemies inside. Or prove it can't be done. Fight
- Level order traversal (BFS with a queue) The Castle Floors Clear the castle one whole floor at a time. Only the front of the queue moves. Fight
- Lowest common ancestor (BST) The Family Tree Two monsters, one family tree. Find their closest common ancestor in one walk down. Fight
- Permutations (backtracking) The Line-Up Four heroes, one line. List all 24 orders without skipping one. Fight
- Quicksort The Pivot Sort the army with one pivot at a time. Swap the weaker ones left, then lock the pivot in. Fight
- Longest common subsequence (dynamic programming) The Ancient Scrolls Find the most runes both scrolls share, in order. Fill the table, then trace them back. Fight
- Grid dynamic programming The Castle Road Right or down only. Count every road from the knight to the castle. Fight
- Euclid's algorithm (GCD) The Brick Towers Find the biggest brick that measures both towers, in as few cuts as Euclid. Fight
- Rabin-Karp (rolling hash) The Cursed Book Roll the hash across the book. Find every cursed word, and don't fall for the fakes. Fight
- Sliding window maximum (monotonic deque) The Window King Who rules each window? Crown the right king, every step. Fight
- Staircase search The Sorted Vault Find 42 in 4 steps. Every row and every column is sorted. Fight
- Counting sort The Tally Sort the whole army without a single comparison. Fight
- Maximum depth of a binary tree (recursion) The Tall Tree How tall is the monster tree? Let the answers bubble up from the leaves. Fight
- Interval scheduling (greedy by earliest end) The Arena Fit the most boss fights into one arena. No two at once. Fight
- Combination sum (backtracking) The Exact Change Coins of 3, 5 and 7. Find every way to pay exactly 15. Fight
- Word break (dynamic programming) The Spell Splitter A spell with no spaces. Can it be split into spellbook words? Fight
- Dijkstra's algorithm (shortest paths with a heap) The Dragon's Cave Fire always takes the cheapest tunnel. Settle the caves in its order and reach the dragon. Fight
- Next greater element (monotonic stack) The Tower Brawl Who blocks whose view? Find every tower's next taller neighbour in one walk. Fight
- Heap (priority queue) The Boss Queue Always fight the strongest monster first. Keep the pyramid in order, one swap at a time. Fight
- Backtracking The Eight Queens No queen may attack another. Place them row by row, and back up when you hit a dead end. Fight
- Trie (prefix tree) The Spell Book Type three letters and it already knows your word. Teach it how. Fight
- LRU cache (least recently used) The Full Inventory Your bag is full and you just found a sword. Who gets thrown out? Fight
- The XOR trick The Imposter Everyone came in pairs except one. Find the imposter with a single variable. Fight
- Quickselect The 5th Strongest Find the 5th strongest monster without sorting anyone. Every round, throw one side away. Fight
- Merge sort The Army Sort Split the army until every soldier stands alone. Then merge it back into one perfect line. Fight
- Flood fill (DFS or BFS on a grid) The Burning Isles How many islands? Scan the map, set each new one on fire, and count it once. Fight
- Binary search on the answer The Hungry Boss Find the slowest speed that still clears every pile in 8 hours. Fight
- Prefix sums The Gold Towers Stack the gold once, then answer any stretch with one subtraction. Fight
- Edit distance (dynamic programming) The Word Duel Turn KITTEN into SITTING in the fewest edits. Fill the grid, then replay the moves. Fight
- Coin change (dynamic programming) The Coin Fight Pay exactly 6 gold in the fewest coins. Greedy says 3. Beat it. Fight
- Sweep with a min-heap The Meeting Boss Ten meetings on the calendar. Book them all in as few rooms as you can. Fight
- Recursion The Doom Tower Move the tower one disk at a time, never big on small. Follow the call stack. Fight
- Reservoir sampling The Endless Parade Hold one monster. Make sure every monster had the same chance. Fight
- Missing number (sum and XOR) The Escape One monster escaped. Find its cage with one number in your head. Fight
- Big O: n² vs n log n The Big O Showdown Two heroes, one speed. Call each hero's work, then watch who wins at a million. Fight
- Binary search tree lookup The Door Maze A tree of numbered doors. Find door 42 in 3 steps, without opening the rest. Fight
- Subsets (backtracking) The Loot Bag Every item is a yes or no. Pack every possible bag without missing one. Fight
- Back-of-the-envelope estimates The Napkin Size a chat app, a photo service and an LLM API before the clock runs out. Fight
- Rotate a grid in place The Crooked Portrait Turn the portrait a quarter clockwise, one tile in your hand at a time. Fight
- Stack (simplify a path) The Mole King Follow the path one piece at a time. Dig in, climb up, or stay put. Fight
- Prefix sums + binary search The Loot Goblin Stack its loot weights end to end, then find who owns each roll in 4 peeks. Fight
- Shortest job first (min-heap) The Lone Smith One anvil, a queue of orders. Always forge the quickest order that's already here. Fight
- Cycle detection (three colours) The Haunted Halls Some halls loop forever. Unroll your string, walk every door, and mark the safe rooms. Fight
- Tree DP (rob or skip) The Night Owl Rob a house and its neighbours below must be left alone. Solve the tree from the leaves up. Fight
- Interval DP The Echo Bat Its cry must read the same both ways. Fill the table, shortest pieces first. Fight