Graph Theory37 sections · 1633 units
Open in Course

LeetCode 1514 Path with Maximum Probability - Problem Statement

Adapting Dijkstra for products

Problem: Path with Maximum Probability Task: Edges have probabilities. Find path from start to end that maximizes the product of probabilities. Convert: log(prob)\log(\text{prob}) turns products into sums.

Maximizing product = maximizing sum of logs. Or use max-heap Dijkstra variant: relax if prob[u] * w > prob[v]. Start with prob[start] = 1. This problem shows that Dijkstra works for any monotone relaxation, not only addition. You just swap the min-heap for a max-heap and reverse the comparison.