BeginnerAbout 15 min

    Complexity Analysis (Big-O)

    Read the full article on Substack

    6 min read.

    Build real intuition for how O(1), O(log n), O(n), O(n log n), O(n²), and O(2ⁿ) actually diverge as input size grows — and practice recognizing which class a piece of code belongs to, the single most common warm-up question in any technical interview.

    Think of it this way: Imagine four different ways to find a friend's phone number: flip through every page of a phone book (linear), or use the fact that it's alphabetized to keep splitting the search range in half (logarithmic), or — if you're truly unlucky — check every possible combination of names against every possible combination of digits (exponential). The number of pages barely matters for the first two even as the book gets huge. It matters enormously for the last one.

    1248161
    124816O(1)O(log n)O(n)O(n log n)O(n²)O(2ⁿ)

    Double n each step and count what each loop shape really does.

    1/7

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Name the growth rate

    Sort

    Sort each piece of code by its time complexity.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    O(1)

    Drop items here

    O(log n)

    Drop items here

    O(n)

    Drop items here

    O(n²)

    Drop items here
    6 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    A function with a single loop that runs n times, and inside it a nested loop that also runs n times — what is its time complexity?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going