My java7 solution


#1
public class Solution {
    public int firstMissingPositive(int[] nums) {
        int n = nums.length;
        if(n == 0) return 1;
        Arrays.sort(nums);
        if(nums[n-1] <= 0) return 1;
        int x = 0;
        int m = nums[n-1];
        for(int i = 0; i < n; i++) {
            if(nums[i] > 0) {
                x = i;
                break;
            }
        }
        int i = 1;
        while(i != m) {
            if(i < nums[x]) return i;
            else if(i > nums[x]) x += 1;
            else i += 1;
        }
        return m + 1;
    }
}