You are viewing a single comment's thread. Return to all comments →
We only need to solve the equation: x1 + Cv1 = x2 + Cv2, add preconditions and that's all. Here is my submission:
public static void determineKangaroos(int x1, int v1, int x2, int v2) { int dx = x1 - x2; int dv = v2 - v1; if(dv == 0) { System.out.println("NO"); } else if((dx % dv == 0) && (dx / dv > 0)) { System.out.println("YES"); } else { System.out.println("NO"); } }
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 →
We only need to solve the equation: x1 + Cv1 = x2 + Cv2, add preconditions and that's all. Here is my submission: