Determine whether a message can reach a destination router from a source router.
Unlock detailed company stats for this questionUpgrade
You are given a list of routers with their 2D location coordinates, a source router, a destination router and a range value. Each router that receives a message broadcasts it to the other routers in range, and whenever a router broadcasts a message it shuts down permanently. Distance between routers is Euclidean distance. Write a method that determines whether a message starting at the source router can reach the destination router.
Example: router A at (0, 0), B at (0, 8), C at (0, 17), D at (11, 0), range 10, source A, destination D. A's message reaches B, B's message reaches C, but D never receives it.
Expect follow-ups like
- How would you update the solution if messages that arrive at the destination at the same time collide and are discarded, assuming travel time is proportional to distance?
Community answers
No answers contributed by the community yet.


