Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. def solution(a):
  2. the_set = set()
  3. for element in a:
  4. if element > 0:
  5. the_set.add(element)
  6.  
  7. if len(the_set) < 1:
  8. return 1
  9.  
  10. for element in range(0, len(the_set)):
  11. if element + 1 not in the_set:
  12. return element + 1
  13.  
  14. return len(the_set) + 1
  15.  
  16.  
  17. assert solution([1, 3, 6, 4, 1, 2]) == 5
  18.  
  19. assert solution([1, 2, 3]) == 4
  20.  
  21. assert solution([-1, -3]) == 1
  22.  
  23. print("Ran Successfully")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement