Binary search tree
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Fri Nov 9 17:45:19 EST 2007
maxim.novak at gmail.com a écrit :
> Hi,
>
> I have to get list of URLs one by one and to find the URLs that I have
> more than one time(can't be more than twice).
>
> I thought to put them into binary search tree, this way they'll be
> sorted and I'll be able to check if the URL already exist.
What about a set ?
s = set()
for url in urls:
if url in s:
print "already have ", url
else:
set.add(url)
More information about the Python-list
mailing list