Hackerrank Kangaroo Problem Java Solution

preview_player
Показать описание
Solutions for Hackerrank Kangaroo problem.

-~-~~-~~~-~~-~-
Please watch: "CSES problem #4: Increasing Array"
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Can you please explain how the iteration will happen to find the remainder is 0 for x1, v1, x2, v2. As per the logic in static method, it'll check for the input of x1, v1, x2, v2 and when the iteration will happen?

mathiazhagansampath
Автор

Not good at explaining things. These are beginner problems and you took zero amount of time to explain the basics.

MrAndrewLawrence
Автор

x1=0 v1=1 x2=0 v2=1 in this case your solution is false
my solution :
static String kangaroo(int x1, int v1, int x2, int v2) {
if(x1==0 &x2==0 && v1==v2) return "yes";
else if(v1<=v2) return "NO";
return (x2-x1) % (v1-v2) == 0 ? "YES" : "NO";
}

ahamedsaja
visit shbcf.ru