Given two lists, list1
and list2
list3 = filter(lambda x: x in list1,list2)
This returns the intersection of the
The complexity could be O(nm)
where n
is the size of list1
and m
is the size of list2
. However this analysis although plausible depends on the underlying python implementation of intersection (which might use sorting so the complexity could be O(logn+logm)
or sth)
In order to experimentaly test this and verify the result, use this: