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

12 lines
280 B
Python

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