leetcode/0217_contains-duplicate/python3/solution.py

12 lines
280 B
Python
Raw Permalink Normal View History

2022-04-21 07:54:02 +00:00
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
counts = {}
for num in nums:
counts[num] = counts.get(num, 0) + 1
if counts[num] > 1:
return True
return False