class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
# 1.用哈希表
if len(nums) == 0:
return False
hashmap = dict()
for num in nums:
if num not in hashmap:
hashmap[num] = 1
else:
return True
return False
# 2.用set,因为set中的元素是唯一的
if len(nums) == 0:
return False
return False if len(nums) == len(set(nums)) else True