Solve “Network Delay Time” & “Path with Maximum Probability” Using Dijkstra [LeetCode 743, 1514]
Vložit
- čas přidán 25. 07. 2024
- Tutorial for how to use Dijkstra’s shortest path algorithm to solve coding interview questions.
We will solve “Network Delay Time” [LeetCode 743] and “Path with Maximum Probability” [LeetCode 1514]
Both are important graph coding questions commonly asked in programming interviews.
I recommend watching the Dijkstra video before this one. Link here -
Dijkstra's algorithm & code explanation: • Dijkstra’s Algorithm f...
Timestamps -
0:00 - Intro
0:23 - Network Delay Time
4:49 - Path with Maximum Probability
You are back !! That's a new year gift Shiran :D
Haha thanks 😆
very great explanation
graph theory is one of my favourite topic :)
one next video, I need on project ideas 💡.🧘♂️
Great explanation
Thanks for the explanation , it was crystal clear :)
You’re welcome :) glad you enjoyed it
Thank you.
Thanks for this explanation ...keep posting :)
Working on it :)
I was thinking to make the PQ sort them with (1 - probability of passing )
I coded the same in java but it is not passing for test case 14
can't we use max heap to find the maximum probability?
It will be like finding the maximum distance but using dijkstra!
It worked for my submission, so i am kind of just curious if we can use dijkstra to find maixmum distance ?
```
class Solution {
public:
double maxProbability(int n, vector& edges, vector& succProb, int start, int end) {
vector g[n];
for(int i=0;i
Yes we can :) it’s equivalent to negating the distances and finding the minimum. I chose to negate because it requires a bit less changes to the original dijkstra algorithm.
@@ShiranAfergan Thanks for the quick clarification.
And your videos are really helpful Shiran, keep posting
Adding to my list. Thanks for suggesting 👌🏽