ALGORITHMICSGitHub ↗

Code-driven animation · word-synced narration

Algorithms are transitions. Watch the transitions.

Static diagrams show a state — the interesting part is what happens between states. Every animation here is TypeScript, rendered at 4K.

94/94

Data Structures & Algorithms

35 problems
  • 01234
    DSA 7 min
    Arrays and Strings

    Why contiguity is the whole advantage, and what it costs when you insert in the middle.

  • DSA 8 min
    Backtracking

    Trying every possibility without trying every possibility — how one rejection prunes a whole branch.

  • DSA 8 min
    Binary Search

    Why halving beats scanning, and the one sentence that has to stay true for the loop to be correct.

  • 00101100= 44
    DSA 7 min
    Bit Manipulation

    What integers actually look like in memory, and the handful of tricks worth memorising.

  • ··no two adjacent
    DSA 5 min easy
    Can Place Flowers

    Plant as early as possible — and the function that quietly rewrites its caller's garden.

  • numsnums again
    DSA 6 min easy
    Concatenation of Array

    A three-line problem that is really about Go slices — capacity, copying, and who owns the array.

  • 27379seen twice
    DSA 6 min easy
    Contains Duplicate

    The first problem where a set beats a nested loop — and what Go uses for a set.

  • DSA 9 min
    Dynamic Programming

    Recursion that stops repeating itself — and how to find the state that makes it work.

  • DSA 9 min
    Graphs and Shortest Paths

    Four algorithms, and the one property of your graph that decides which of them is allowed.

  • DSA 8 min
    Greedy

    Take the best option in front of you — and the proof you owe before you are allowed to.

  • eatteatanbataetantabt
    DSA 6 min medium
    Group Anagrams

    A canonical key turns grouping into one map insert — and Go lets the key be an array.

  • 012
    DSA 8 min
    Hash Maps

    Why average O(1) is a statement about spread, and what happens when the spread fails.

  • max
    DSA 7 min
    Heaps and Priority Queues

    A tree hidden inside an array, and why knowing less is cheaper than knowing everything.

  • ahbgdcabc
    DSA 6 min easy
    Is Subsequence

    Two pointers that only move forward — and the byte-versus-rune slip that crashes it.

  • egadand back again
    DSA 6 min easy
    Isomorphic Strings

    A consistent one-to-one substitution — and why checking one direction is not enough.

  • Hi you!·
    DSA 4 min easy
    Length of Last Word

    Two lines with the standard library, or one backwards scan — and why the trailing space is the whole problem.

  • DSA 7 min
    Linked Lists

    Pointer surgery without losing the list, and the dummy node that removes every edge case.

  • flowflowfligfl
    DSA 5 min easy
    Longest Common Prefix

    Compare down the columns, not along the words — and stop at the first disagreement.

  • a
    DSA 6 min easy
    Majority Element

    Boyer-Moore voting — constant space, and only correct because the problem promises something.

  • DSA 7 min
    Matrix Traversal

    Grids are graphs with invisible edges — and the direction array that keeps the code honest.

  • DSA 8 min
    Merge Sort

    Divide until trivial, then merge — and why the recursion tree gives you the running time for free.

  • DSA 7 min
    Merging Intervals

    Sort by start, sweep once — and the off-by-one that decides whether touching ranges count.

  • DSA 8 min easy
    Next Greater Element

    How a monotonic stack turns a quadratic scan into one pass, and why the stack can never stop being decreasing.

  • 111121
    DSA 5 min easy
    Pascal's Triangle

    Each row from the one above it — the smallest dynamic programming table there is.

  • 22333k
    DSA 5 min easy
    Remove Element

    Removing in place without shifting — one boundary, one pass, and what the return value really is.

  • 18661-1scan backwards
    DSA 5 min easy
    Replace Elements with Greatest Element on Right Side

    Walk backwards and the quadratic scan disappears — the smallest suffix-aggregate problem.

  • abcba
    DSA 7 min
    Sliding Window

    Why the window never moves backwards, and how that turns a quadratic scan linear.

  • DSA 6 min
    Stacks and Queues

    Two rules for "what next", and why the choice changes which order you explore.

  • 12534
    DSA 7 min
    Trees and Traversals

    Four orders, one recursion, and what each one is actually for.

  • cdao
    DSA 7 min
    Tries

    Paying per character instead of per string, and when that trade is worth it.

  • lohi
    DSA 7 min
    Two Pointers

    One pass instead of two loops, and the ordering property that makes discarding safe.

  • 27111539 − 2 = 7
    DSA 6 min easy
    Two Sum

    Store what you need, not what you have — the inversion that makes one pass enough.

  • DSA 7 min
    Union-Find

    Keeping track of who is connected to whom, and the two one-line tricks that make it nearly free.

  • a.b+c@x.comab
    DSA 4 min easy
    Unique Email Addresses

    Normalise, then count the set — and the one part of the address you must not touch.

  • abccaball 0
    DSA 7 min easy
    Valid Anagram

    One tally instead of two — and the Unicode bug hiding in the obvious Go solution.

System Design

18 topics
  • System Design 6 min
    Backpressure

    Telling a fast producer to slow down — and what happens to latency when you do not.

  • System Design 6 min
    Bloom Filters

    "Definitely not there" for a few bits per item — and why the other answer is only a maybe.

  • System Design 7 min
    Caching Strategies

    Where the copy lives, who writes it, and the two hard problems underneath.

  • CA
    System Design 6 min
    CAP and PACELC

    The choice you only make during a partition — and the one you make the rest of the time.

  • edgeorigin
    System Design 6 min
    CDNs and Edge Caching

    The speed of light is the constraint — and the only fix is to already be there.

  • 3 of 5
    System Design 8 min
    Consensus and Raft

    Getting a majority to agree on one value — and the two rules that make it safe.

  • System Design 6 min
    Consistent Hashing

    Why adding a shard should move 1/n of the keys and not all of them.

  • System Design 7 min
    Database Indexing

    Why a B-tree and not a hash map — and the column order that decides whether your index is used at all.

  • System Design 7 min
    Event Sourcing

    Store what happened, derive the current state — and the migration problem you inherit.

  • System Design 6 min
    Idempotency

    Making retries safe — because in a distributed system the client cannot tell failure from a lost reply.

  • System Design 6 min
    Leader Election

    Picking one node to be in charge — and the fencing token that makes it actually safe.

  • System Design 6 min
    Load Balancing

    Spreading requests across servers — and why counting them is not the same as spreading work.

  • System Design 7 min
    Message Queues

    Decoupling producers from consumers — and the delivery guarantee you actually get.

  • System Design 7 min
    Observability

    Asking questions you did not plan for — and why averaging latency hides the outage.

  • System Design 6 min
    Rate Limiting

    Four algorithms, and the boundary bug that makes the simplest one allow double.

  • System Design 7 min
    Replication

    Copies for durability and read capacity — and the lag that makes users see their own writes disappear.

  • System Design 7 min
    Sharding

    Splitting data across machines — and the key choice you cannot easily take back.

  • System Design 6 min
    Write-Ahead Logs

    Write the intention before the change — and get durability, replication and time travel from one idea.

Concurrency & Parallelism

18 topics
  • Concurrency 6 min
    Actors

    One owner per piece of state, reachable only by message — and what that buys you across a network.

  • Concurrency 6 min
    Amdahl's Law

    The part you cannot parallelise sets a ceiling — and it is lower than you think.

  • 7=78
    Concurrency 6 min
    Atomics

    Indivisible operations in hardware — and the loop that turns one into any update you like.

  • Concurrency 5 min
    Condition Variables

    Waiting for a state, not a lock — and why the check has to be a while loop.

  • Concurrency 6 min
    CSP and Channels

    Don't communicate by sharing memory; share memory by communicating.

  • Concurrency 6 min
    Deadlock

    Four conditions, all required — so breaking any one of them is a complete fix.

  • Concurrency 7 min
    Event Loops

    One thread, no blocking — and the queue ordering that decides what actually runs next.

  • Concurrency 5 min
    False Sharing

    Two threads with no shared variable, made slow by sharing 64 bytes.

  • Concurrency 6 min
    Happens-Before

    The relation that decides what one thread is allowed to see of another.

  • Concurrency 6 min
    Lock-Free Structures

    Progress guarantees, and the memory-reclamation problem that makes them hard.

  • abcacb
    Concurrency 6 min
    Memory Models

    What the hardware and the compiler are allowed to reorder — and why x86 lets bad code pass.

  • Concurrency 7 min
    Mutexes and Locks

    One holder at a time — and why the lost update happens on the line you thought was atomic.

  • Concurrency 6 min
    Read-Copy-Update

    Readers pay nothing at all — and the writer waits for them to leave before freeing anything.

  • Concurrency 5 min
    Semaphores

    A counter with a queue attached — and why it is not a mutex with extra steps.

  • Concurrency 6 min
    Structured Concurrency

    Tasks that cannot outlive the block that started them — goto, but for threads.

  • Concurrency 6 min
    Thread Pools

    Reuse the workers, queue the work — and the two questions that decide the size.

  • Concurrency 5 min
    Threads and Processes

    What is shared decides everything else — cost, safety, and how a crash spreads.

  • Concurrency 6 min
    Work Stealing

    Idle workers take from the busy — and the end of the deque they take from is the whole trick.

Design Patterns

23 patterns
  • Patterns 5 min
    Abstract Factory

    Whole families that must match — and the cost of adding one more kind of thing.

  • Patterns 6 min
    Adapter

    Making an incompatible interface fit — and the one file that should know the vendor's vocabulary.

  • Patterns 5 min
    Bridge

    Two things that vary independently, kept from multiplying.

  • Patterns 6 min
    Builder

    Assembling a complicated object step by step — and the validation you can only do at the end.

  • Patterns 5 min
    Chain of Responsibility

    Pass the request along until somebody claims it — and the case nobody handles.

  • Patterns 6 min
    Command

    A request as an object — and the undo stack you get almost for free.

  • Patterns 6 min
    Composite

    Treating one thing and many things identically — and the method that does not belong on a leaf.

  • Patterns 6 min
    Decorator

    Adding behaviour by wrapping rather than subclassing — and why the order of the wrappers is a real decision.

  • Patterns 5 min
    Facade

    One door into a subsystem — and why the door must not become the only way in.

  • Patterns 6 min
    Factory Method

    Letting a subclass decide what to construct — and why a plain function is usually enough.

  • Patterns 5 min
    Flyweight

    Sharing the heavy part between many objects — and the split that makes it possible.

  • Patterns 5 min
    Interpreter

    A grammar as a class hierarchy — and why you should almost always use a parser generator instead.

  • Patterns 6 min
    Iterator

    Walking a collection without knowing its shape — and why laziness is the part that matters.

  • Patterns 5 min
    Mediator

    A hub instead of a mesh — and the risk that the hub becomes the program.

  • Patterns 5 min
    Memento

    A snapshot that only its owner can read — and why undo usually wants commands instead.

  • Patterns 6 min
    Observer

    One-to-many notification without the sender knowing who is listening — and the leak it invites.

  • Patterns 5 min
    Prototype

    Copying an existing object instead of constructing one — and the depth of the copy.

  • Patterns 6 min
    Proxy

    A stand-in with the same interface — and the fact that callers cannot tell is both the feature and the hazard.

  • Patterns 6 min
    Singleton

    One instance, globally reachable — and why the second half of that is the problem.

  • Patterns 6 min
    State

    Behaviour that follows the mode — and how the illegal transitions stop being reachable.

  • Patterns 6 min
    Strategy

    The algorithm as a parameter — and why in most languages it is now just a function.

  • Patterns 5 min
    Template Method

    The skeleton fixed, the steps varied — inheritance's one genuinely good use, and its limits.

  • Patterns 6 min
    Visitor

    Adding an operation without editing the classes — and the price it charges for that.