Skip to content

Instantly share code, notes, and snippets.

@ta1hia
Created March 15, 2016 04:53
Show Gist options
  • Save ta1hia/1cd9bafcb5c803c38531 to your computer and use it in GitHub Desktop.
Save ta1hia/1cd9bafcb5c803c38531 to your computer and use it in GitHub Desktop.
# you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
def solution(A):
# write your code in Python 2.7
N = len(A)
C = [0] * N
res = 0
for i in A:
if i > 0 and i <= N:
C[i-1] += 1
for i in range(1, N+1):
if not C[i-1]:
res = i
break
if not res: res = N + 1
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment