217. Contains Duplicate
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 12, 2024
Last updated : July 01, 2024
Related Topics : Array, Hash Table, Sorting
Acceptance Rate : 62.33 %
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return not len(set(nums)) == len(nums)
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
prev = set()
for num in nums :
if num in prev :
return True
prev.add(num)
return False