classSolution:deffirstMissingPositive(self,nums: List[int]) ->int:# sort the list, make postivie integers in order from index of 0# negative or duplicated elements are at the end i =0while i <len(nums):if nums[i]<=0or nums[i]-1>=len(nums)or nums[i]== i+1or nums[i]== nums[nums[i]-1]: i +=1else: otherIndex = nums[i]-1 temp = nums[i] nums[i]= nums[otherIndex] nums[otherIndex]= temp# find the missing onefor i inrange(len(nums)):if nums[i]!= i +1:return i+1returnlen(nums)+1