Google | Onsite | Router Broadcast & Shut Down

Let's define a kind of message called "Broadcast & Shut Down."

When a router receives this message, it broadcasts the same message to all other routers within its wireless range.
Then, that router shuts down, and can no longer send or receive messages.

For example, Router A is at (0, 0); Router B is at (0, 8); Router C is at (0, 17); Router D is at (11, 0). 

If the wireless range is 10, when Router A sends a message, it could first reach B; the message from Router B would further reach Router C but Router D would never receive this message.

Given a list of routers' locations (their names and the corresponding 2D coordinates), tell me whether a message from Router A can reach Router B. 
  1. Write a method / function with appropriate input and output arguments.
  2. Write test case's. Also, mention the Time and Space complexity for the same.
Comments (17)