class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
maxpos=0
for num in nums:
if num>maxpos:
maxpos=num
minpos=maxpos
for num in nums:
if num<minpos and num>0:
minpos=num
if minpos>1:
return 1
for i in range(minpos+1,maxpos+1):
if i in nums:
continue
else:
return i
return maxpos+1
网友评论