We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
First check if(v1>v2) or else return "NO" because if v1 < v2, the first kangaroo will not caught second kangaroo even at any high values
and if this check is false then check (x2 - x1) % (v2 - v1) == 0
if((v1>v2) && ((x2-x1) % (v2 - v1)))
return "YES";
return "NO";
This passes all test cases.
Cookie support is required to access HackerRank
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 →
First check if(v1>v2) or else return "NO" because if v1 < v2, the first kangaroo will not caught second kangaroo even at any high values and if this check is false then check (x2 - x1) % (v2 - v1) == 0
This passes all test cases.