문제

Python has a default searching function which is:

x in [x,y,z,]

Where x,y,z can be any integers or characters, but this is a default sequential search and I want to know how I can use a manual hashing search in python.

도움이 되었습니까?

해결책

Use a set() instead:

x in {x,y,z}

This uses a hash table under the hood, so searches are O(1).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top