Python Ma - Sajha Mobile
SAJHA MOBILE
Python Ma
Posts 2 · Viewed 4512 · Go to Last Post
comingsoon
· Snapshot 0
Like · Likedby · 0
 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



nepalinanu2013
· Snapshot 78
Like · Liked by · 0
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)
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 3 · Viewed 261
· Posts 1 · Viewed 72
· Posts 19 · Viewed 3137 · Likes 1
· Posts 1 · Viewed 92
· Posts 1 · Viewed 80
· Posts 1 · Viewed 125
· Posts 1 · Viewed 135
· Posts 4 · Viewed 1143
· Posts 1 · Viewed 253
· Posts 1 · Viewed 163



Your Banner Here
Travel Partners
Travel House Nepal