Skip to content

Instantly share code, notes, and snippets.

@shabarin
Last active September 15, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shabarin/7a5d8e5bcf0088b5c56862463a57eefe to your computer and use it in GitHub Desktop.
Save shabarin/7a5d8e5bcf0088b5c56862463a57eefe to your computer and use it in GitHub Desktop.
def solutionC(a):
g = {}
maxnum = 1
for i in range(0, len(a)):
if a[i] > 0:
g[a[i]] = 1
maxnum = max(maxnum, a[i])
for j in range(1, maxnum+2):
if j not in g:
return j
return 1
def solutionD(a):
positive = filter(lambda x: x >= 0, a)
positive.sort()
if len(positive) == 0:
return 1
prev = positive[0]
for i in range(1, len(positive)):
if (prev+1) < positive[i]:
return prev+1
else:
prev = positive[i]
return prev+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment