my python solution


  • 0
    M

    class Solution(object):

    def firstMissingPositive(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if not nums or sorted(nums)[-1]<1: return 1
        for i in range(1,sorted(nums)[-1]+1):
            if i not in nums: return i
        return i+1

Log in to reply
 

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