Last active
June 22, 2016 01:20
-
-
Save tiagopereira17/120b27f95e6ab34eec55487e42107685 to your computer and use it in GitHub Desktop.
The frog is located at position X and wants to get to a position greater than or equal to Y. The frog always jumps a fixed distance, D. Count the minimal number of jumps that the frog must perform to reach its target.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FrogJump { | |
public int countJumps(int X, int Y, int D) { | |
if(X > Y) { | |
return 0; | |
} | |
return (int) Math.ceil((Y - X) / (double) D); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment