public static int findSmallestMissingByIndexing(int[] A) {
        if (A == null || A.length == 0) {
            logger.severe("Invalid input.");
            throw new IllegalArgumentException("Invalid input.");
        }

        for (int i = 0; i < A.length; i++) {
            int indexToNegate;
            if (A[i] < 0) {
                indexToNegate = (-1 * A[i]) - 1;
            } else {
                indexToNegate = A[i] - 1;
            }
            if (indexToNegate < 0 || indexToNegate >= A.length) {
                continue;
            }
            A[indexToNegate] *= -1;
        }

        int i = 0;
        while (i < A.length) {
            if (A[i] > 0) {
                System.out.println(i + 1);
                return i + 1;
            }
            i++;
        }

        System.out.println(i);
        return i;
    }