getting a different number

Go Back home
 1 def get_different_number(arr):
 2   if len(arr) == 1:
 3     if arr[0] > 0:
 4       return 0
 5     else:
 6       return 1
 7   mi = min(arr)
 8   ma = max(arr)
 9   if mi != 0:
10     return 0
11   s = set(arr)
12   for i in range(mi, ma+1):
13     if i not in s:
14       return i
15   return ma + 1