[codility]FrogRiverOne

Python代码如下:

def solution(X, A):
    # write your code in Python 2.6
    checkCrucialTable = [False]*X
    crucialCnt = 0
    for i in xrange(0, len(A)):
        if not checkCrucialTable[A[i]-1]:
            checkCrucialTable[A[i]-1] = True
            crucialCnt += 1
            if crucialCnt == X:
                return i
    return -1
    pass


你可能感兴趣的:([codility]FrogRiverOne)