Algorithm/codility

Lesson3. Time Complexity - FrogJmp

nuKeguyS 2018. 7. 23. 15:44

FrogJmp - Count minimal number of jumps from position X to Y.

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

문제요약

개구리가 X에서 Y이상으로 가려고 하고, 한 번에 고정된 길이 D만큼 점프를 한다고 하면 X에서 Y이상으로 가기 위한 최소 점프 수를 계산

Assume that:

X, Y and D are integers within the range [1..1,000,000,000];

X ≤ Y.

Complexity:

expected worst-case time complexity is O(1);

expected worst-case space complexity is O(1).

풀이