Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.07 KB

_217. Contains Duplicate.md

File metadata and controls

45 lines (33 loc) · 1.07 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 12, 2024

Last updated : July 01, 2024


Related Topics : Array, Hash Table, Sorting

Acceptance Rate : 62.33 %


Solutions

Python

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