Johnder Perez

Step 1 of 6

Big-O notation (time and space)


Big-O describes how work grows as your data grows. O(1): same speed no matter the size (looking up a key in a map). O(n): work grows in step with the data (one pass through a list). O(n²): a loop inside a loop. 1,000 items means 1,000,000 steps. O(log n): halve the problem each step (binary search).

Why it matters when you build with AI: Ask the AI 'what's the Big-O of this?' for any loop over user data. Nested loops over two lists are the number-one cause of 'it was fast in dev, slow in prod'.

Quick check

A loop inside a loop over the same list of n items is…

← Track overview Next: Arrays, linked lists, stacks and queues →