Created
March 15, 2016 04:53
-
-
Save ta1hia/1cd9bafcb5c803c38531 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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