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 779628c commit 18ef494Copy full SHA for 18ef494
1 file changed
Sprint-1/Python/find_common_items/find_common_items.py
@@ -9,15 +9,8 @@ def find_common_items(
9
"""
10
Find common items between two arrays.
11
12
- Time Complexity:
13
- Space Complexity:
14
- Optimal time complexity:
+ Time Complexity: O(n + m) process both sequences
+ Space Complexity:O(n + m) two sets are created
+ Optimal time complexity:O(n + m) must check all elements
15
16
- common_items: List[ItemType] = []
17
- second_sequence_set = set(second_sequence)
18
-
19
- for i in first_sequence:
20
- if i in second_sequence_set and i not in common_items:
21
- common_items.append(i)
22
23
- return common_items
+ return list(set(first_sequence).intersection(second_sequence))
0 commit comments