Thanks Ron, surely set is the simplest way to understand the question, to see whether there is a non-empty intersection. But I did the following thing in a silly way, still not sure whether it is going to be linear time. def foo(): l = [...] s = [...] dic = {} for i in l: dic[i] = 0 k=0 while k <len(s): if s[k] in dic: return True else: pass k+=1 if k == len(s): return False
I am still a rookie, and partly just migrated from Haskell... I am not clear about how making one of the lists a dictionary is helpful -- http://mail.python.org/mailman/listinfo/python-list