Maximum path reliability
A network has n nodes (0..n-1) and undirected links; edges[i] = [a, b] with success probability probs[i] (a float in [0,1]) that a message survives that link. The reliability of a path is the product of its link probabilities. Return the maximum reliability of any path from start to end, or 0.0 if none exists. start may equal end (reliability 1.0). There are at most 10^4 edges.
Implement
max_reliability(n: int, edges: list[list[int]], probs: list[float], start: int, end: int) → floatExamples
in
[3,[[0,1],[1,2],[0,2]],[0.5,0.5,0.2],0,2]out0.25What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[3,[[0,1],[1,2],[0,2]],[0.5,0.5,0.2],0,2]0.25not run yetsample