https://app.codility.com/programmers/lessons/4-counting_elements/
정답률: 88%
시간복잡도:O(N + M)
def solution(N, A):
cnt = [0] * N
maxcnt = 0
for K in range(len(A)):
if A[K]-1 < N:
cnt[A[K]-1] += 1
if cnt[A[K]-1] > maxcnt:
maxcnt = cnt[A[K]-1]
else:
cnt = [maxcnt] * N
return cnt
728x90
반응형
'Problem Solving > Codility' 카테고리의 다른 글
[Python] 4.4. PermCheck (0) | 2021.03.15 |
---|---|
[Python] 4.3. MissingInteger (0) | 2021.03.15 |
[Python] 4.1. FrogRiverOne (0) | 2021.03.13 |
[Python] 3.3. TapeEquilibrium (0) | 2021.03.11 |
[Python] 3.2. PermMissingElem (0) | 2021.03.11 |
댓글