DSA and problem solving

Stage 1 · Lesson 6 of 6

Reading constraints to guess the target complexity

Complexity and Big-O

The limits in a problem statement, called , tell you how fast your solution must be. A typical , the system that runs and checks your code, manages roughly 10^8 simple steps per second. So work backwards from the input size n.

Up to about 20 allows O(2^n). Up to a few thousand allows O(n²). Up to 10^5 or 10^6 needs O(n log n) or O(n).

Up to 10^9 or more needs O(log n) or a formula. Reading constraints before you design tells you which ideas are worth trying, and which (trying everything) will run out of time. It turns this stage from theory into a tool you use on every problem.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Keep handy

Also worth your time

Mark this stage as not done?