Skip to content

Commit a3b23af

Browse files
committed
solve: contains-duplicate
1 parent ee1ad8e commit a3b23af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contains-duplicate/Raft.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def containsDuplicate(self, nums: List[int]) -> bool:
3+
appeared = defaultdict(int)
4+
for n in nums:
5+
if appeared[n] > 0:
6+
return True
7+
appeared[n] += 1
8+
9+
return False
10+

0 commit comments

Comments
 (0)