Math for coding interviews/Linear growth - O(n)

O(n) Linear Time, Explained Visually

If you have 10 items to check, you do 10 steps. 1,000 items? 1,000 steps. The work grows at exactly the same rate as the input.

See it for yourself

A straight diagonal line on a graph. Double the input, double the time. No surprises.

Linear growth - O(n)

If you have 10 items to check, you do 10 steps. 1,000 items? 1,000 steps. The work grows at exactly the same rate as the input.

Visual: A straight diagonal line on a graph. Double the input, double the time. No surprises.

Think of it this way: Reading every page of a book. If the book is twice as long, it takes twice as long to read.

For algorithms: O(n) is usually the target for one-pass algorithms like simple array traversals.

Real-world analogy

Reading every page of a book. If the book is twice as long, it takes twice as long to read.

Why it matters in interviews

O(n) is usually the target for one-pass algorithms like simple array traversals.

Where it shows up on the learning path