Skip to content
Code ReadingCommon Items
Read the Big-O

Common Items

a and b are both lists of n items. How fast is this one-liner? Careful: what does in do on a list?
1def common(a, b):
2 return [x for x in a if x in b]