Big-O and complexity
Read and state the time and space complexity of simple code, compare O(1), O(log n), O(n), O(n log n) and O(n²), and use that to pick the faster approach before you run anything.
Beginner 3 · Data and toolsabout 2 hours5 sections
Quick answer
Big-O notation describes how an algorithm's work grows as its input grows. O(1) stays flat, O(n) grows in step, and O(n²) grows with the square of the input.
Why it matters
Code that is fine on 100 rows can take hours on 10 lakh. Big-O lets you see that coming, and every coding interview asks you to state the complexity of your answer and improve it.
Sign up free to read the whole lesson
The rest of this lesson: 5 parts, video lessons, the best course, practice and a quick check. It is free, takes a few seconds and needs no card.
Accounts are for learners aged 18 and over. Under 18? The quick answer and the first part of every lesson stay open: browse lessons by topic.
Related
Data structures and algorithmsBeginner 3: Data and toolsVideo lessonsBig-O notationHash mapBinary search