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.
Number Line Jumps
Number Line Jumps
Sort by
recency
|
3957 Discussions
|
Please Login in order to post a comment
My Java 8 Solution
C++ solution
def kangaroo(x1, v1, x2, v2): #check if both vectors are same if v1==v2: return 'NO' else: #verify if the intervel where the kangaroos are meeting is grater than 0 as the vectors are moving positively i = math.ceil(((x1-x2)/(v2-v1))) if i > 0 and (x1 + v1*i) == (x2 + i*v2) : return 'YES' else: return "NO"
Bruh what is this comment search on Hackerrank. Trying to see if x1 always starts left of x2. Then you can calculate it without simulating