SHARE
TWEET

Untitled

a guest Apr 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top