Python solution without overflow


  • 0
    H
    class Solution(object):
        def missingNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            missing=len(nums)*(len(nums)+1)/2
            for i in nums:
                missing-=i
            return missing

Log in to reply
 

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