Solve “Network Delay Time” & “Path with Maximum Probability” Using Dijkstra [LeetCode 743, 1514]

Sdílet
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

Komentáře • 16

  • @deathstrokebrucewayne
    @deathstrokebrucewayne Před 2 lety +2

    You are back !! That's a new year gift Shiran :D

  • @anshmakker2965
    @anshmakker2965 Před rokem

    very great explanation

  • @kapilvaishnav6851
    @kapilvaishnav6851 Před 2 lety +1

    graph theory is one of my favourite topic :)
    one next video, I need on project ideas 💡.🧘‍♂️

  • @vinaykenguva362
    @vinaykenguva362 Před 2 lety

    Great explanation

  • @rohalkurup1350
    @rohalkurup1350 Před 2 lety +4

    Thanks for the explanation , it was crystal clear :)

  • @haithamdaana3467
    @haithamdaana3467 Před 2 lety +1

    Thank you.

  • @hansikarastogi230
    @hansikarastogi230 Před 2 lety +2

    Thanks for this explanation ...keep posting :)

  • @hazemabdelalim5432
    @hazemabdelalim5432 Před rokem

    I was thinking to make the PQ sort them with (1 - probability of passing )

  • @shritishaw7510
    @shritishaw7510 Před 2 lety

    I coded the same in java but it is not passing for test case 14

  • @danial6685
    @danial6685 Před 2 lety +4

    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

    • @ShiranAfergan
      @ShiranAfergan  Před 2 lety +2

      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.

    • @danial6685
      @danial6685 Před 2 lety +1

      @@ShiranAfergan Thanks for the quick clarification.
      And your videos are really helpful Shiran, keep posting

    • @ShiranAfergan
      @ShiranAfergan  Před 2 lety

      Adding to my list. Thanks for suggesting 👌🏽