0
Challenge · 18Cost: Time and Space
Big-O: growth, not seconds
Complexityused in ~100% of apps
This is the notation people find intimidating and interviewers ask about constantly. You already understand the idea completely. You have been counting steps for a whole lesson. All that is left is the name.
Core idea. Big-O is shorthand for the shape of the count you just learned to work out. O(n) means the work grows in step with the input. O(n squared) means it grows by multiplication. It describes growth, never seconds.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
what the notation is saying
O(1)the same work whatever the sizearr[5], map.get(k), push
O(log n)halve what is left, each stepbinary search
O(n)once per itemone loop, one pass
O(n log n)a pass, for each halvingsorting
O(n²)once per pairloop inside a loop
O(2ⁿ)doubles with every extra itemtrying every combination
The whole notation is a sentence about growth, written short.
↑ play a little first, then dig in