

def firstMissingPositive(self, A):
    '\n        Bucket Sort without extra space\n        O(n)\n\n        Extra space is eliminated by using the array A itself as a storage\n\n        :param A: a list of integers\n        :return: an integer\n        '
    if (not A):
        return 1
    i = 0
    length = len(A)
    while (i < length):
        current = A[i]
        if ((current <= 0) or (current > length) or (A[(current - 1)] == current)):
            i += 1
        else:
            (A[(current - 1)], A[i]) = (current, A[(current - 1)])
    for i in xrange(length):
        if (A[i] != (i + 1)):
            return (i + 1)
    return (A[(- 1)] + 1)

dataset/ETHPy150Open algorhythms/LeetCode/040 First Missing Positive.py Solution.firstMissingPositive/original