Code RoomMaximum path reliability
MediumPrep Room Coding #1083

Maximum path reliability

CodingReliability & on-callMid–Senior~30 min

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) → float
Examples
in[3,[[0,1],[1,2],[0,2]],[0.5,0.5,0.2],0,2]out0.25
What 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
InputExpectedGot
[3,[[0,1],[1,2],[0,2]],[0.5,0.5,0.2],0,2]0.25not run yetsample