点击打开链接
class Solution {
public:
int firstMissingPositive(vector<int>& nums) {
int n = nums.size();
vector<bool> rec(n+2);
for(int i=0; i<n; i++){
if(nums[i]<n+2 && nums[i]>0){
rec[nums[i]] = true;
}
}
for(int i=1; i< n+2; i++){
if(!rec[i]) return i;
}
return n+2;
}
};