Big-O Cheat Sheet for Your Next Interview

Julia Zhou
2 min readJan 4, 2021

What is Big-O?

It’s the longest amount of time any function is going to take given the worst-case scenario of the input.

If you’re hoping to land your first role as a Software Engineer, you’d probably already know it’s important to have some understanding of Big-O before you get called in for a technical assessment. Here is a quick cheat sheet/review to help you prep.

  • O(n!): Big-O n factorial is the worst possible time! (ex. n=4, n=4*3*2*1)
  • O(n log n): reasonable amount of time
  • O(n): iterating over entire dataset, commonly seen as a single for loop in a function
  • O(log n): always strive for log n, very fast — best solution
  • O(1): will always return solution in the same amount of time

To quickly determine the Big O for a function, count the number of iterations within a function. If a single for loop is O(n), the Big-O for the function below would be O(n³).

--

--