Author: Rupanjan Hari
Tester: Rupanjan Hari
This problem is like the problem of two cars running at two different velocities, where you have to determine when will they meet. The story has twist in this case, the starting position are different and you have to print ‘YES’ if they ever meet otherwise ‘NO’.
The starting positions and velocities of the car will be giver alternately. Receive them and calculate their pace.
The code snippet (written in C) below shows the checking process.
if (x1==x2 && v1==v2)
//Run the loop to detect the whether the Kangaroo’s will cross each other. If so set the ‘flag’ otherwise keep it as ‘0’
Run this code for each input x1,v1,x2,v2.
click here to see the solution