Maximum path reliability

Write codeMedium30 min

Your task

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.

Examples

max_reliability(n: int, edges: list[list[int]], probs: list[float], start: int, end: int) -> float
Example 1
Inputmax_reliability(3, [[0, 1], [1, 2], [0, 2]], [0.5, 0.5, 0.2], 0, 2)
Output0.25