PYTHON: Easy to Understand

  • -1

    Sorted the list to make it more simple. Let me know if you have any questions.

    class Solution(object):
        def missingNumber(self, nums):
            v = 0
            nums = sorted(nums)
            if nums[0] == 1: return 0
            for i in range(0,len(nums)-1):
                if not nums[i+1]:
                    return nums[i]+1
                if nums[i]+1 != nums[i+1]:
                    return nums[i]+1
                    v = nums[i]+1
            return v + 1

Log in to reply

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