My Python Easy solution.. beats 100%


  • 0
    P

    class Solution(object):
    def findErrorNums(self, nums):
    """
    :type nums: List[int]
    :rtype: List[int]
    """
    l = len(nums)
    s = l*(l+1)/2
    missing = s-sum(set(nums))
    dup = sum(nums)-sum(set(nums))
    return [dup,missing]


Log in to reply
 

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