Demonstrate O(1) set membership vs O(n) list search
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Demonstrate O(1) set membership vs O(n) list search. Create data_list = list(range(100000)) and data_set = set(range(100000)). Check if 99999 is in each. Print both results and print 'Set lookup is O(1)'.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.