Why nested loops are O(n²)

An outer loop runs n times; for each of those, an inner loop runs n times. Every (i, j) pair is one unit of work — and the pairs fill an n × n grid. The area you light up is the operation count.

n = Loop:
Cells visited
0
double n → 4× the work
n481632
16642561,024