public int firstMissingPositive(int[] A) {
    	int marked[] = new int[A.length + 1];
    	
    	for (int i = 0; i < A.length; i++)
    		if (A[i] > 0 && A[i] <= A.length)
    			marked[A[i]]++;
    	
    	for (int i = 1; i <= A.length; i++)
    		if (marked[i] == 0) return i;
    	
    	return A.length + 1;
    }