본문 바로가기

IT/알고리즘

[코딜리티] - Lesson 3. FrogJmp


안녕하세요 남갯입니다.





public class FrogJump {
public static int solution(int X, int Y, int D) {
// write your code in Java SE 8
int offset = 0;
if ((Y - X) % D > 0) {
offset = 1;
}
return (Y == X) ? 0 : (((Y - X) / D) + offset);

}
}