1514. Path with Maximum Probability
You are given an undirected weighted graph of n
nodes (0-indexed), represented by an edge list where edges[i] = [a, b]
is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i]
.
Given two nodes start
and end
, find the path with the maximum probability of success to go from start
to end
and return its success probability.
If there is no path from start
to end
, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.
Example 1:
Example 2:
Example 3:
Constraints:
n
<= 104start
, end
< n
start
!= end
a
, b
< n
a
!= b
succProb.length
== edges.length
<= 2*104succProb[i]
<= 1Dijkstra's algorithm, TLE when n=10000
BFS, Beats 93.16%
Jerry28 June, 2023