Simplle Python solution


  • 0
    C

    class Solution(object):

    def missingNumber(self, nums):
        n = len(nums)
        sum = (n+0)*(n+1)/2
        for i in nums:
            sum = sum-i
        return sum

Log in to reply
 

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