```
public static int firstMissingPositive(int[] nums) {
Arrays.sort(nums);
int cnt = 1;
for(int i = 0 ; i < nums.length; i++){
if(nums[i] > 0){
if(nums[i] == cnt - 1 ) continue;
else if(nums[i] != cnt) return cnt;
else cnt++;
}
}
return cnt;
}
```