COMPILED CANVAS
DSA IN JAVA

Find the Big O of ANY code in 10 seconds

4 rules. That's all.

Tap to start →

RULE 1

Loops multiply

for (i = 0; i < n; i++) for (j = 0; j < n; j++) count++; // n × n

A loop inside a loop: multiply their counts. n × n = O(n²).

1 of 4 · keep tapping →
RULE 2

Steps in a row add

n + n = O(n)

One loop, then another loop: n + n = 2n, which is still O(n).

2 of 4 · keep tapping →
RULE 3

Doubling or halving = log n

124816

If i doubles or n halves each step, that loop is O(log n).

3 of 4 · keep tapping →
RULE 4

Recursion: count the calls

n=10
n=20
n=30

Calls × work per call. Fibonacci with two calls each time grows like 2ⁿ.

4 of 4 · keep tapping →
⚠ MOST PEOPLE MISS THIS

The mistake

Calling a loop O(n) when its counter doubles. That's O(log n).

QUICK QUIZ

Can you get it?

Tap an answer. The full video explains why.

📸 SCREENSHOT THIS

Cheat sheet

  • Nested loops: multiply
  • Loops in a row: add
  • Doubling/halving: log n
  • Drop constants
  • Recursion: calls × work
COMPILED CANVAS

Want the full lesson?

▶ Watch the full videoPractice + free notes

Free DSA in Java course. Subscribe to Compiled Canvas on YouTube.

Watch the full video