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.
Check the difference between the two kangaroos on each jump if they come to become 0 then yes or no if the difference goes to negative-This is the main logic other anomaly(Infinite looping problem) is if both distances are equal from start theyll never produce negative or 0 so print no and see if the second kangaroo is way ahead than the first one from start if yes then print "No"
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 →
Will this be optimal?
Check the difference between the two kangaroos on each jump if they come to become 0 then yes or no if the difference goes to negative-This is the main logic other anomaly(Infinite looping problem) is if both distances are equal from start theyll never produce negative or 0 so print no and see if the second kangaroo is way ahead than the first one from start if yes then print "No"