Skip to content

Commit b89edee

Browse files
committed
contains duplicate solution
1 parent d975b97 commit b89edee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contains-duplicate/jungsiroo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def containsDuplicate(self, nums: List[int]) -> bool:
3+
# Slow - tc : O(n) / sc : O(1)
4+
5+
"""return len(set(nums)) != len(nums)"""
6+
7+
# Fast - tc : O(n) / sc : O(n)
8+
check = set()
9+
10+
for num in nums:
11+
if num in check:
12+
return True
13+
check.add(num)
14+
15+
return False
16+
17+
18+

0 commit comments

Comments
 (0)