← Back to Kurakani

Python Ma

Original Post

Hello, how to find the list element that whether it is on other lists or not? I know by the loop method (found= True). If you know better way please let me know. Thanks. L1 = [1,2,3,4,5] L2=[2,3,6] L3=[1,6,8] L4 = [3,10] result: 1: L1,L3 2: L1,L2 3: L1,L2,L4 6: L2,L3

comingsoon
Apr 25, 2013 10:11 PM · 12,257 views
1 Reply
nepalinanu2013 Apr 26, 2013 1:26 AM
not sure if this is the best way to do it: load the elements to python disctionary ( that would be O(n) operation) for each element in array, check if it exists in the disctionary , that would be another O(n) operation because hash lookup is O(1)
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant