Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def next_id(arr):
- from itertools import groupby
- #your code here.
- # 1 sort array 0-> max
- # 2 kill duplicates
- # 3 compare counter with array items - return current counter if unequal
- # return counter++
- def sortCopyArr(arr):
- b = arr[:]
- b.sort()
- return b
- def removeDuplEl(arr):
- new_arr = [el for el, _ in groupby(arr)]
- return new_arr
- if (len(arr) == 0):
- return 0
- arr = removeDuplEl(sortCopyArr(arr))
- i = 0
- for i in range(len(arr)):
- if(i != arr[i]):
- return i
- #print (i)
- return (i + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement