Created
January 12, 2017 21:39
-
-
Save gbazilio/20ad704e43bc30aa14b0fda55f3e5563 to your computer and use it in GitHub Desktop.
Codiligty - Frog jump leaves
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
def solution(X, A): | |
count_array = [0] * (X) | |
leaves = 0 | |
for index in xrange(len(A)): | |
if count_array[A[index] - 1] == 0: | |
count_array[A[index] - 1] = 1 | |
leaves += 1 | |
if leaves == X: | |
return index | |
return -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment