TGViewer
Python Learning Python Learning @python_bds Β· 5.74K subscribers
Post #1266 733
πŸš€ Python Time Complexity Cheat Sheet

βœ… List
β€’ Access by index β†’ O(1)
β€’ Append β†’ O(1)
β€’ Insert at beginning β†’ O(n)
β€’ Delete from middle β†’ O(n)
β€’ Search (in) β†’ O(n)
Best for: Ordered collections where fast indexing matters.

βœ… Dictionary (dict)
β€’ Lookup β†’ O(1)
β€’ Insert β†’ O(1)
β€’ Update β†’ O(1)
β€’ Delete β†’ O(1)
Best for: Fast lookups using keys.

βœ… Set
β€’ Add β†’ O(1)
β€’ Remove β†’ O(1)
β€’ Membership test β†’ O(1)
Best for: Removing duplicates and fast membership checks.

βœ… Tuple
β€’ Access β†’ O(1)
β€’ Search β†’ O(n)
Best for: Read-only collections that shouldn't change.
  • ❀ 3
More from @python_bds
  1. Oct 8, 2026πŸ› This Python Bug Looks Random, But It Isn't Look at this: functions = [] for i in range(…
  2. Oct 6, 2026🐍 Python Performance Optimization Python Performance Optimization: Make Your Code Faster…
  3. Oct 4, 2026Python Set Methods ✍️
  4. Oct 3, 2026Post #1310
  5. Oct 1, 2026🐍 Python Beginner Notes
  6. Sep 30, 2026🧠 return vs print() in Python These are not interchangeable. def add(a, b): print(a + b)…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’