```
public class Solution {
public int firstMissingPositive(int[] nums) {
int max = 0;
for(int i : nums){
max = i > max ? i : max;
}
boolean[] bool = new boolean[max+2];
Arrays.fill(bool, false);
for(int i : nums){
if(i >= 0)
bool[i] = true;
}
int result = 0;
for(int i = 1; i < max + 2; i++){
if(bool[i] == false){
result = i;
break;
}
}
return result;
}
}
```