Most Reliable Relay Path for a Message Across Edge Servers
Last updated: November 29, 2026
Quick Overview
Given an undirected network of edge servers where each link delivers a message with probability p, return the highest probability that a message sent from server start reaches server end. Return 0 if end is unreachable.
Meta
November 29, 20260
0
0 solved
Given an undirected network of edge servers where each link delivers a message with probability p, return the highest probability that a message sent from server start reaches server end. Return 0 if end is unreachable.
Fits Meta's phone screen, where a candidate is expected to adapt a textbook algorithm to a twist within about 20 minutes. Messenger and WhatsApp traffic hops between edge PoPs, so reliability-weighted routing is a natural framing. The interviewer checks whether you recognize that multiplying probabilities is still a monotone path cost that Dijkstra can handle.
What the Interviewer Expects
- Recognize this as a best-path problem where path value is a product of edge weights in [0, 1]
- Explain why a max-heap Dijkstra is correct: extending a path can never increase its probability
- Skip stale heap entries instead of using a decrease-key structure
- Return early when the target is popped
- Handle unreachable targets and start equal to end
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why would this break if some links had a multiplier greater than 1?
- How would you avoid floating point underflow on very long paths?
- How would you return the actual path, not just its probability?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
nservers, a list of undirected links(u, v, p)with0 <= p <= 1, and two server ids. - Output: the maximum product of link probabilities over any path from
starttoend, or0.0i...
High-Level Design
Taking -log(p) turns each probability into a non-negative cost and products into sums, so this is exactly shortest path. We can skip the transform and run Dijkstra directly on products with a max-he...