You are viewing a single comment's thread. Return to all comments →
public static int jump(int startPoint, int distance){ return startPoint + distance; } public static String checkRes(int x1, int v1, int x2, int v2){ if ((x2 > x1 && v2 >= v1) || (x1 > x2 && v1 >= v2)) { return "NO"; } if ((v1>10000) || (v2>10000)){ return "NO"; } int res1 = jump(x1, v1); int res2 = jump(x2, v2); if(res1 == res2){ return "YES"; }else{ return checkRes(res1, v1, res2, v2); } } public static String kangaroo(int x1, int v1, int x2, int v2) { return checkRes(x1, v1, x2, v2); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →