What is the time complexity of the in operator on a list in Python?
Correct answer
D. O(n)
6 views
D. O(n)
6 views
Membership testing scans the list linearly, unlike sets and dicts which average O(1).
Asked in: Python Interview Lists
https://docs.python.org/3/tutorial/datastructures.htmlNot sure why the answer is D? Ask here and get an explanation.