Interview glossary / Technical rounds
Big O notation
Also called: Time complexity · Space complexity · Big-O
A way to describe how an algorithm's running time or memory grows with input size, such as O(n) or O(n log n), ignoring constants.
Big O describes the growth rate in the worst case (unless stated otherwise). O(1) is constant, O(log n) grows slowly, O(n) grows linearly, O(n²) grows with the square of the input. Space complexity applies the same idea to memory.
In interviews it is used to compare approaches: a brute-force O(n²) solution versus an O(n) one using a hash map, for example.
In an interview
State the time and space complexity of every solution you propose, and explain where it comes from ("one pass over the array, plus a set of up to n items").