Skip to content

Commit 593e448

Browse files
committed
refactor find_common_items
1 parent c5a314e commit 593e448

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Sprint-1/Python/find_common_items/find_common_items.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ def find_common_items(
99
"""
1010
Find common items between two arrays.
1111
12-
Time Complexity:
13-
Space Complexity:
14-
Optimal time complexity:
12+
Time Complexity: O(n) - nested loop
13+
Space Complexity: O(n)
14+
Optimal time complexity: O(n)
1515
"""
16-
common_items: List[ItemType] = []
17-
for i in first_sequence:
18-
for j in second_sequence:
19-
if i == j and i not in common_items:
20-
common_items.append(i)
21-
return common_items
16+
return list(set(first_sequence) & set(second_sequence))

0 commit comments

Comments
 (0)