Member-only story
Big-O Complexities
All Around Us
🟢 O(1) — Constant Time
Doing something in the same time, no matter how big the input is.
🧃 Example:
You grab a juice box from the fridge.
Doesn’t matter if the fridge has 2 or 200 drinks — you know exactly where it is.
📌 Key Idea: One step. Always.
🔵 O(n) — Linear Time
The more you have, the longer it takes.
🧦 Example:
You search for your favorite socks in a messy pile.
More socks = More searching.
📌 Key Idea: You check one by one.
🔶 O(n²) — Quadratic Time
You compare every pair.
🎒 Example:
You’re making sure every toy in your bag gets along with every other toy.
You ask: “Teddy, do you like Dino?” — for every possible pair.
📌 Key Idea: For each item, you check all others.
🔷 O(n³) — Cubic Time
Triple nested work.
🧁 Example:
You’re baking a 3-layer cake and trying every combination of frosting, sponge, and…