Skip to content

Commit 001e7cd

Browse files
committed
Sync LeetCode submission - Contains Duplicate (python3)
1 parent f2b4e13 commit 001e7cd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
class Solution:
22
def containsDuplicate(self, nums: List[int]) -> bool:
3-
s = set(nums)
4-
return True if len(s) != len(nums) else False
3+
hashset = set()
4+
5+
for n in nums:
6+
if n in hashset:
7+
return True
8+
hashset.add(n)
9+
return False

0 commit comments

Comments
 (0)