Loading problem...
You are tasked with navigating through an undirected weighted network consisting of n nodes, labeled from 0 to n - 1. The network's structure is described by a list of connections where each edges[i] = [nodeA, nodeB] represents a bidirectional link between nodeA and nodeB. Each connection has an associated reliability factor given by succProb[i], which indicates the probability (a value between 0 and 1) that traversing this specific link will succeed.
When traveling along a path that consists of multiple links, the overall success probability of that path is computed as the product of all the individual link probabilities along the way. For instance, if you traverse two links with probabilities 0.6 and 0.8 respectively, the overall probability of successfully completing that route is 0.6 × 0.8 = 0.48.
Given a starting node and a destination node, your objective is to determine the maximum success probability achievable when traveling from the start to the destination. If no valid path exists between the two nodes (i.e., they are in disconnected components of the network), return 0.
Your solution will be considered correct if the returned value differs from the expected answer by no more than 1e-5 (0.00001).
n = 3
edges = [[0,1],[1,2],[0,2]]
succProb = [0.5,0.5,0.2]
start = 0
end = 20.25There are two possible routes from node 0 to node 2: • Direct route 0 → 2 with probability 0.2 • Indirect route 0 → 1 → 2 with probability 0.5 × 0.5 = 0.25 The maximum success probability is 0.25, achieved via the indirect path.
n = 3
edges = [[0,1],[1,2],[0,2]]
succProb = [0.5,0.5,0.3]
start = 0
end = 20.3There are two possible routes from node 0 to node 2: • Direct route 0 → 2 with probability 0.3 • Indirect route 0 → 1 → 2 with probability 0.5 × 0.5 = 0.25 The maximum success probability is 0.3, achieved via the direct path.
n = 3
edges = [[0,1]]
succProb = [0.5]
start = 0
end = 20.0Node 0 is only connected to node 1. There is no path from node 0 to node 2, so the result is 0.
Constraints