In interviews, you never say "This is O(2N + 5)." You simplify. Big O is about the trend, not the exact math. These two rules let you reduce any expression to its essential form.
Rule 1: Drop the Constants
If your code has two loops that run one after another (not nested), it takes $2N$ steps.
- Math: $O(2N)$
- Big O: $O(N)$
- Why? As N grows toward infinity, multiplying by a constant doesn't change the shape of the curve. A linear function is still linear whether it's $N$ or $100N$. Constants are a property of the hardware and implementation, not the algorithm's fundamental behavior.
Rule 2: Drop Non-Dominant Terms
If your code has a nested loop ($N^2$) AND a single loop ($N$), it takes $N^2 + N$ steps.
- Math: $O(N^2 + N)$
- Big O: $O(N^2)$
- Why? If $N = 1{,}000{,}000$:
- $N^2 = 1{,}000{,}000{,}000{,}000$
- $N = 1{,}000{,}000$
- The $N$ term is 0.0001% of the total. At scale, it is irrelevant noise. We only keep the term that grows the fastest, because that term will eventually dominate all others.
These rules exist because Big O describes an asymptotic upper bound — the behavior as N approaches infinity. At infinity, constants and lower-order terms vanish.