Find the Duplicate Number LeetCode solution in Python

1
# Runtime: 1523 ms (Top 9.74%) | Memory: 34 MB (Top 8.51%)
2
class Solution:
3
def findDuplicate(self, nums: List[int]) -> int:
4

5
dictx = {}
6

7
for each in nums:
8
if each not in dictx:
9
dictx[each] = 1
10
else:
11
return each

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0