Skip to content

Instantly share code, notes, and snippets.

@makafanpeter
Last active April 14, 2019 22:41
Show Gist options
  • Save makafanpeter/f2dfbdbb58490e863344039304587f8b to your computer and use it in GitHub Desktop.
Save makafanpeter/f2dfbdbb58490e863344039304587f8b to your computer and use it in GitHub Desktop.
def solution(a):
the_set = set()
for element in a:
if element > 0:
the_set.add(element)
if len(the_set) < 1:
return 1
for element in range(0, len(the_set)):
if element + 1 not in the_set:
return element + 1
return len(the_set) + 1
assert solution([1, 3, 6, 4, 1, 2]) == 5
assert solution([1, 2, 3]) == 4
assert solution([-1, -3]) == 1
print("Ran Successfully")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment