One line solution in python O(n)


  • 0
    S
        def missingNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            return (len(nums) + 1) * len(nums) / 2 - sum(nums)

Log in to reply
 

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