标签:
class Solution: # @param {integer[]} nums # @return {integer} def firstMissingPositive(self, nums): Length = len(nums) for i in range(Length): while nums[i] != i+1: if nums[i] <= 0 or nums[i] > Length or nums[i] == nums[nums[i]-1]: break temp = nums[nums[i]-1]; nums[nums[i]-1] = nums[i]; nums[i] = temp for j in range(Length): if nums[j] != j+1: return j+1 return Length+1
Leetcode 41 First Missing Positive
标签:
原文地址:http://blog.csdn.net/andrew9tech/article/details/46608015