Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13981

Best time complexity of python 'if x in y' when checking a list [duplicate]

$
0
0

I am analysing some code I have written for its best and worst time complexity. I have been stuck for a while trying to understand what pythons if x in y best time complexity is as I haven't found many resources mentioning it.My understanding is that in the best case scenario list = [3, 1, 4, 5, 7], element 3 would be retrieved in constant time as it exists at the beginning of the list.


Viewing all articles
Browse latest Browse all 13981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>