Skip to content

Instantly share code, notes, and snippets.

@ta1hia
Created March 14, 2016 05:57
Show Gist options
  • Save ta1hia/14189f215909c992fe98 to your computer and use it in GitHub Desktop.
Save ta1hia/14189f215909c992fe98 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):
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