Created
March 14, 2016 05:57
-
-
Save ta1hia/14189f215909c992fe98 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): | |
N = len(A) | |
if not N: return 0 | |
count = N | |
result = 1 | |
A_ = [0] * N | |
for i in A: | |
if i > N: | |
result = 0 | |
break | |
elif i <= N and not A_[i-1]: | |
A_[i-1] = 1 | |
count -= 1 | |
if count: | |
result = 0 | |
return result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment