# Algorithms—41.First Missing Positive

public class Solution {
public int firstMissingPositive(int[] nums) {
for (int i = 0; i < nums.length; i++) {
if (nums[i]!=i+1) {
if (nums[i]<=nums.length&&nums[i]>0&&nums[nums[i]-1]!=nums[i]) {
int k=nums[nums[i]-1];
nums[nums[i]-1]=nums[i];
nums[i]=k;
i--;
}
}
}
for (int i = 0; i < nums.length; i++) {
if (nums[i]!=i+1) {
return i+1;
}
}
return nums.length+1;

}
}

• 本文已收录于以下专栏：

## LeetCode 41. First Missing Positive

41. First Missing Positive Given an unsorted integer array, find the first missing positiveinteger. ...

## DAY28：leetcode #41 First Missing Positive

Given an unsorted integer array, find the first missing positive integer. For example, Given [1,...

## leetcode 41. First Missing Positive

1.题目 Given a collection of candidat...

## Leetcode41. First Missing Positive

Leetcode First Missing Positive

## [leetcode]41. First Missing Positive,C++/python实现，hard难度

[leetcode]41. First Missing Positive,C++/python实现，hard难度

## [LeetCode - 桶排序] 41. First Missing Positive

1 问题 Given an unsorted integer array, find the first missing positive integer. For example, ...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)