Simple Python Solution


  • 0
    A

    class Solution(object):
    def containsDuplicate(self, nums):
    """
    :type nums: List[int]
    :rtype: bool
    """
    if not nums:
    return False
    if len(nums) == 1:
    return False
    dict1 = {}
    for num in nums:
    dict1[num] = dict1.get(num,0) + 1
    print dict1[num]
    if dict1[num] > 1:
    return True
    return False


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.