If you try to find the same value among the two lists in Python, it is usually
for i in list1:
for j in list2:
if i == j :
print(i)
I found it using the for statement twice, but I changed it to a set, and then I found the intersection built-in function If you use it, it's easy to find it. In the set, how do you find it? I wonder if I can find it quickly. (It's too fast to just be a difference in the structure of the data.) I'm sure it's a different Does the set sort to find the intersection?
python list set
It's almost the same as selecting from a table with indexes and searching from a table without indexes.
And three, each element has a hash value that's indexed. It will be sorted, and binary research is available. You just have to go through the list.
© 2024 OneMinuteCode. All rights reserved.