MEDIUMasked at 2 companies

Path with Maximum Probability

A medium-tier problem at 65% community acceptance, tagged with Array, Graph, Heap (Priority Queue). Reported in interviews at BlackRock and 1 others.

Founder's read

You're given a graph where edges have probabilities, not weights, and you need to find the path that maximizes the product of edge probabilities from start to end. BlackRock and TCS both ask this one. The trap is treating it like a standard shortest-path problem. You can't just flip signs and use Dijkstra's directly on probabilities. The math changes because you're maximizing a product, not minimizing a sum. This is the kind of problem where the obvious instinct fails in the live OA. StealthCoder surfaces the working solution in seconds if you hit it cold during your assessment.

Companies asking
2
Difficulty
MEDIUM
Acceptance
65%

Companies that ask "Path with Maximum Probability"

If this hits your live OA

Path with Maximum Probability is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The key insight is that maximizing a product of probabilities is equivalent to maximizing the sum of their logarithms. But there's a faster way: use Dijkstra's algorithm with max-heap semantics instead of min-heap. Track the maximum probability to reach each node, then explore neighbors in decreasing probability order. Common mistake: trying to use standard shortest-path distance logic. Another trap: not handling the heap correctly when probabilities decrease as you go deeper. The algorithm terminates when you pop the destination node, but only if you've found a better path. The acceptance rate sits at 65 percent, meaning a significant chunk of submissions fail on edge cases or the heap logic. If you blank on whether to use log or heap inversion during the assessment, StealthCoder solves it without proctor visibility.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Path with Maximum Probability recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Path with Maximum Probability interview FAQ

Why can't I just negate the probabilities and use standard Dijkstra's?+

Dijkstra's minimizes sums, not products. Negating probabilities between 0 and 1 breaks the monotonicity guarantee Dijkstra relies on. You need to track max probability to each node instead, using a max-heap to explore the most promising paths first.

Is this still asked at top companies?+

Yes. BlackRock and TCS both report it. The 65 percent acceptance rate suggests it's a meaningful filter, not a trivial problem. Companies use it to test graph traversal and optimization thinking under pressure.

What's the trick to avoiding TLE?+

Use a max-heap and track the best probability to each node. Skip any path that arrives at a node with lower probability than you've already seen. This prunes the search space efficiently and prevents redundant exploration of worse paths.

How does this relate to Shortest Path as a topic?+

It's a shortest-path variant where the metric is probability product, not distance sum. The underlying algorithm is still Dijkstra's, but the heap is inverted and the comparison logic changes. Understanding this connection is how you generalize shortest-path thinking beyond weighted graphs.

What happens if there's no path to the destination?+

Return 0. If the destination is unreachable, you never pop it from the heap, and your max probability stays 0. Check this boundary case before submitting, as some solutions skip it and fail test cases.

Want the actual problem statement? View "Path with Maximum Probability" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.