You are viewing a single comment's thread. Return to all comments →
In Java 15
public static String kangaroo(int x1, int v1, int x2, int v2) {
//x1 + v1*f = x2 + v2*f //(x1-x2)+(v1-v2)*f = 0 String result = ""; double f = (double) (x2-x1)/(v1-v2); if(f < 0 || (f*10)%10 != 0){ result = "NO"; } else { result = "YES"; } return result; }
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 →
In Java 15
public static String kangaroo(int x1, int v1, int x2, int v2) {