mycode  76.39%

class Solution(object):
    def containsDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        if len(nums) == 0 or len(nums) == 1:
            return False
        return not (len(set(nums)) == len(nums))

 

参考  

最快:

class Solution(object):
    def containsDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        hasht = {}
        for num in nums:
            if num not in hasht:
                hasht[num] = True
            else:
                return True
        return False

相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-08-10
  • 2022-02-11
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2021-09-12
  • 2022-03-01
  • 2021-12-20
  • 2021-08-24
相关资源
相似解决方案