Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice
in the array, and it should return false if every element is distinct.
Answer with python:
class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
if len(nums)==0:
return False
numbers=set() '''定义一个空集合'''
numbers.update(nums) '''添加数组进集合'''
if len(numbers)==len(nums):
return False
else:
return True