본문 바로가기
Problem Solving/Codility

[Python] 3.2. PermMissingElem

by 부르르 2021. 3. 11.

https://app.codility.com/programmers/lessons/3-time_complexity/

 

3. Time Complexity lesson - Learn to Code - Codility

Count minimal number of jumps from position X to Y.

app.codility.com


정답률: 100%

시간 복잡도: O(N) or O(N * log(N))

def solution(A):

    N = len(A)

    total = int((N+1)*(N+2)/2)

    answer = total - sum(A)

    return answer
728x90
반응형

'Problem Solving > Codility' 카테고리의 다른 글

[Python] 4.1. FrogRiverOne  (0) 2021.03.13
[Python] 3.3. TapeEquilibrium  (0) 2021.03.11
[Python] 3.1. FrogJmp  (0) 2021.03.07
[Python] 2.2. OddOccurrencesInArray  (0) 2021.03.07
[Python] 2.1. CyclicRotation  (0) 2021.03.06

댓글