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