[codility] Counting Elements (python)
728x90
반응형
정렬하면 nlogn이 되고 이 방식은 O(n)으로 풀린다
def solution(A):
# write your code in Python 3.6
n=1000001
check=[False]*n
for e in A:
if e>=1:
check[e-1]=True
for i in range(n):
if check[i]==False:
return i+1
728x90
반응형
'codility' 카테고리의 다른 글
[codility] sorting: MaxProduct of three (0) | 2020.10.28 |
---|---|
[codility] Distinct (python) (0) | 2020.10.14 |
[codility] max counters (python) (0) | 2020.10.14 |
[codility] TapeEquilibrium (python) (0) | 2020.10.14 |
[codility] Solution to Binary-Gap by codility (python) (0) | 2020.10.14 |
TAGS.