SMALL
안녕하세요 남갯입니다.
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);
}
}
LIST
'IT > 알고리즘' 카테고리의 다른 글
[코딜리티] - Lesson 3. TapeEquilibrium (0) | 2019.08.05 |
---|---|
[코딜리티] - Lesson 3. PermMissingElem (0) | 2019.08.05 |
[코딜리티] - Lesson 2. CyclicRotation (0) | 2019.07.29 |
[코딜리티] - Lesson 2. OddOccurrencesInArray - 1 (0) | 2019.07.29 |
[코딜리티] - Lesson 1. BinaryGap (0) | 2019.07.29 |