Codility FrogJmp

Solution

class Solution {
    public int solution(int X, int Y, int D) {
        int count = (Y - X) / D;
        int remainder = (Y - X) % D;
        if (remainder>0) {
            return count+1;
        }
        return count;
    }
}
  • 다른 사람 풀이
public int solution(int X, int Y, int D) {
  double divideNum = (Y - X) * 1.0 / D;
      return (int) Math.ceil(divideNum);
}