Skip to main content
All Questions

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. Write a method that determines whether a message starting at the source router can reach the destination router. Distance between routers is Euclidean distance.

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.

Follow-up: discard message collisions. If the destination receives 2 or more messages at the same time, the message is considered collided and discarded, i.e. not reachable. Only messages that do not collide with others at the same time are reachable. Assume the time for a message to reach any router is proportional to the distance.

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.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.