[codility] frog river one (python)

728x90
반응형

1 ~ x까지 나오면 현재의 인덱스(초)를 리턴해준다

O(n)

# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
def solution(X, A):
    # write your code in Python 3.6
    dict=collections.defaultdict(int)
    for i,e in enumerate(A):
        dict[e]=1
        if len(dict)==X:
            return i
            
    return -1
        
728x90
반응형
TAGS.

Comments