We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 177e3af commit ef4739bCopy full SHA for ef4739b
Sprint-1/Python/find_common_items/find_common_items.py
@@ -20,10 +20,12 @@ def find_common_items(
20
second_set = set(second_sequence)
21
22
# Find common items using set lookup: O(n) time
23
+ seen_items = set()
24
common_items = []
25
for item in first_sequence:
- if item in second_set and item not in common_items:
26
+ if item in second_set and item not in seen_items:
27
common_items.append(item)
28
+ seen_items.add(item)
29
30
return common_items
31
0 commit comments