본문 바로가기
Problem Solving/Codility

[Python] 3.1. FrogJmp

by 부르르 2021. 3. 7.

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(1)

def solution(X, Y, D):
    
    if X == Y:
        return 0

    answer = qoutient = (Y-X)//D
    remainder = (Y-X)%D
        
    if remainder != 0:
        answer = qoutient+1
    
    return answer
728x90
반응형

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

[Python] 3.3. TapeEquilibrium  (0) 2021.03.11
[Python] 3.2. PermMissingElem  (0) 2021.03.11
[Python] 2.2. OddOccurrencesInArray  (0) 2021.03.07
[Python] 2.1. CyclicRotation  (0) 2021.03.06
[Python] 1.1. BinaryGap  (0) 2021.03.06

댓글