Kangaroo in java
Kangaroo Hacker Rank Solution in Java. You are choreograhing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location and moves at a rate of meters per jump.
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x1 = in.nextInt(); int v1 = in.nextInt(); int x2 = in.nextInt(); int v2 = in.nextInt(); while(x2<100000000){ x1+=v1; x2+=v2; if(x1==x2){System.out.println("YES"); break; } } if(x1!=x2)System.out.println("NO"); } }