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
|
3933 Discussions
|
Please Login in order to post a comment
I am struggling to understand why on earth this usecase expects YES: x1 = 0 x2 = 3 v1 = 4 v2 = 2 If the first jump gets x1 at position 4 and x2 at position 5 then in teh second jump x1 surpass x2 and stays ahead from there onwards.
def kangaroo(x1, v1, x2, v2):
def kangaroo(x1, v1, x2, v2): if v1 > v2 and (x1 - x2) % (v1 - v2) == 0: return 'YES' return 'NO'
This is my solution in perl
Here is my c++ solution, you can have the explanation here : https://youtu.be/bRVVCCmXN0Y