https://app.codility.com/programmers/lessons/4-counting_elements/
정답률: 100%
시간복잡도: O(N)
def solution(X, A):
check = [1] + [0] * X
cnt = 0
for K in range(len(A)):
if check[A[K]] == 0:
check[A[K]] = 1
cnt += 1
if cnt == X:
return K
if cnt != X:
return -1
728x90
반응형
'Problem Solving > Codility' 카테고리의 다른 글
[Python] 4.3. MissingInteger (0) | 2021.03.15 |
---|---|
[Python] 4.2. MaxCounters (0) | 2021.03.14 |
[Python] 3.3. TapeEquilibrium (0) | 2021.03.11 |
[Python] 3.2. PermMissingElem (0) | 2021.03.11 |
[Python] 3.1. FrogJmp (0) | 2021.03.07 |
댓글