Python simple math solution. O(N) without extra memory


  • 0
    A
    class Solution(object):
        def missingNumber(self, nums):
            size = len(nums)
            sum_all = ((1 + size) * size)/2
            return sum_all - sum(nums)
    

Log in to reply
 

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