Skip to content

Interview Solver

FeaturesPricingHelp
Sign In
FeaturesPricingHelpSign In
All Tools

Big O Cheat Sheet

Quick reference for time and space complexity of common algorithms and data structures. Essential for coding interviews at FAANG and other tech companies.

Complexity Scale (Best to Worst)

1O(1)Constant10 elements = 1 op
2O(log n)Logarithmic10 elements ≈ 3 ops
3O(n)Linear10 elements = 10 ops
4O(n log n)Linearithmic10 elements ≈ 33 ops
5O(n²)Quadratic10 elements = 100 ops
6O(2^n)Exponential10 elements = 1,024 ops
7O(n!)Factorial10 elements = 3,628,800 ops

Data Structure Operations

Data StructureAccessSearchInsertDeleteSpace
ArrayO(1)O(n)O(n)O(n)O(n)
StackO(n)O(n)O(1)O(1)O(n)
QueueO(n)O(n)O(1)O(1)O(n)
Linked ListO(n)O(n)O(1)O(1)O(n)
Hash TableO(1)O(1)O(1)O(1)O(n)
Binary Search TreeO(log n)O(log n)O(log n)O(log n)O(n)
AVL TreeO(log n)O(log n)O(log n)O(log n)O(n)
HeapO(1)O(n)O(log n)O(log n)O(n)

* Average case complexity shown. Worst case may differ (e.g., Hash Table worst case is O(n)).

Sorting Algorithms

AlgorithmBestAverageWorstSpace
Quick SortO(n log n)O(n log n)O(n²)O(log n)
Merge SortO(n log n)O(n log n)O(n log n)O(n)
Heap SortO(n log n)O(n log n)O(n log n)O(1)
Bubble SortO(n)O(n²)O(n²)O(1)
Insertion SortO(n)O(n²)O(n²)O(1)
Selection SortO(n²)O(n²)O(n²)O(1)
Counting SortO(n + k)O(n + k)O(n + k)O(k)
Radix SortO(nk)O(nk)O(nk)O(n + k)

Common Code Patterns

Single loop through arrayO(n)
for (let i = 0; i < n; i++)
Nested loopsO(n²)
for i... for j...
Binary search / divide & conquerO(log n)
while (left < right) mid = (left + right) / 2
Sorting then searchingO(n log n)
sort() + binary search
Hash map lookupO(1)
map.get(key)
Two pointersO(n)
while (left < right)
Sliding windowO(n)
fixed or variable window
BFS/DFS on graphO(V + E)
Visit all vertices and edges
Generate all subsetsO(2^n)
Backtracking / bit manipulation
Generate all permutationsO(n!)
Backtracking with swaps

Interview Tips

✓

Always state complexity: After explaining your solution, mention both time and space complexity.

✓

Consider trade-offs: Sometimes O(n) space can reduce O(n²) time to O(n). Discuss these trade-offs.

✓

Drop constants: O(2n) simplifies to O(n). Focus on the dominant term.

✓

Amortized analysis: Some operations (like dynamic array resize) are O(1) amortized even if occasionally O(n).

Need help during your coding interview?

Get AI-powered real-time assistance with Interview Solver-live hints, solutions, and explanations during your actual coding interviews.

Try Interview Solver

More Free Tools

STAR Method BuilderResume Bullet GeneratorTotal Comp CalculatorThank You Email Generator
Interview Solver
  • Home
  • Pricing
  • Sign in
  • Contact
  • Blog
  • Companion
  • Help Center
  • Use Cases
  • Software Engineer
  • Product Manager
  • Misc
  • Privacy Policy
  • Terms and Conditions
  • Discord Community
  • Affiliate Program
  • Compare
  • All Comparisons
  • vs Final Round AI
  • vs UltraCode
  • vs Interview Coder
  • vs LockedIn AI
  • vs AI Apply
  • Free Tools
  • ATS Resume Checker
  • STAR Method Builder
  • Salary Lookup
  • Big O Cheat Sheet
  • Total Comp Calculator
  • View All →
  • Interview Questions
  • Google Questions
  • Amazon Questions
  • Microsoft Questions
  • Meta Questions
  • Apple Questions
  • TikTok Questions
  • View All →
© 2026 Interview Solver, Inc. All rights reserved.