python set() sum() beat 100%

  • 0
    class Solution(object):
        def findDuplicate(self, nums):
            :type nums: List[int]
            :rtype: int
            a = set(nums)
            n = len(nums)-len(a)
            return (sum(nums) - sum(a))/n

  • 0

    Don't you understand what 'O(1) extra space' means?

Log in to reply

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