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
- Discussions
Number Line Jumps
Number Line Jumps
Sort by
recency
|
125 Discussions
|
Please Login in order to post a comment
I'm confused by this one. 0 3 4 2 So, the steps should be as follows... 0 3 6 9 for kangaroo 1 4 6 8 10 for kangaroo 2
The expected answer is YES, but the steps don't line up. The question reads like the kangaroos must jump at the same time.
public static String kangaroo(int x1, int v1, int x2, int v2) { if (v1 == v2) { return (x1 == x2) ? "YES" : "NO"; } if ((x1 - x2) % (v2 - v1) == 0 && (x1 - x2) / (v2 - v1) >= 0) { return "YES"; }
}
}
Thought about as just intersecting lines.
Python3 1 liner: