We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f2b4e13 commit 001e7cdCopy full SHA for 001e7cd
Leetcode/problems/contains_duplicate/solution.py
@@ -1,4 +1,9 @@
1
class Solution:
2
def containsDuplicate(self, nums: List[int]) -> bool:
3
- s = set(nums)
4
- return True if len(s) != len(nums) else False
+ hashset = set()
+
5
+ for n in nums:
6
+ if n in hashset:
7
+ return True
8
+ hashset.add(n)
9
+ return False
0 commit comments