Path with Maximum Probability | Using Dijkstra's | GOOGLE | Leetcode-1514 | Live Code

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ • 56

  • @tauquirahmed1879
    @tauquirahmed1879 Рік тому +28

    I went to the Graph concepts playlist and revised Dijkstra from there, believe me I didn't had to watch this video to solve this problem. 😇🥰

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +7

      You just made my day Tauquir ❤️❤️❤️
      And Congratulations on your new internship offer ❤️❤️❤️
      Keep growing. We have to achieve more and more and more

    • @tauquirahmed1879
      @tauquirahmed1879 Рік тому +2

      @@codestorywithMIK thanks bhaiya.... You have played an important role in my life for getting this opportunity. The OA round which was based on DSA was a cakewalk for me. 🥰🥹

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +13

      so glad to know.
      Please always keep following points in your mind -
      1) Keep working hard, never settle.
      2) Enjoy as well in life
      3) Work hard to fulfill your dreams + your PARETN’S dreams
      All the best

    • @tauquirahmed1879
      @tauquirahmed1879 Рік тому

      @@codestorywithMIK ❣️

    • @gui-codes
      @gui-codes 3 місяці тому

      same bro

  • @souravjoshi2293
    @souravjoshi2293 Рік тому +2

    No can teach Graph like you on internet.
    I will repeat, you are the "KING OF GRAPHS"

  • @codestorywithMIK
    @codestorywithMIK  Рік тому +5

    Dijkstra's Based Problems -
    github.com/MAZHARMIK/Interview_DS_Algo/tree/master/Graph/Dijkstra'a%20Based%20Problems
    Dijkstra's Videos in my Graph Concepts & Qns Playlist - ua-cam.com/video/xQ3vjWwFRuI/v-deo.html
    Thank you to all of you for your kind reviews and comments❣

  • @floatingpoint7629
    @floatingpoint7629 Рік тому +8

    i had already seen dijkstra video so i was on the right the track but i was using min heap 😅 thanks for the explanation.

  • @FanIQQuiz
    @FanIQQuiz Рік тому +2

    You have insane level of clarity on how to teach ❤❤❤

  • @Still_standing418
    @Still_standing418 Рік тому +2

    Literally no one teaches like you bro, thanks for the amazing explanation

  • @aws_handles
    @aws_handles 3 місяці тому +3

    Love your explanation. Graph ko halwa bana diya hai aapne.
    Congratulations in advance for 63K . Soon 100k 😎

  • @rohan8758
    @rohan8758 3 місяці тому +2

    Awesome video on variant on Dijkstra's algorithm. Thansk Mik for your dedication towards teaching.

  • @wearevacationuncoverers
    @wearevacationuncoverers Рік тому

    Literally no one teaches like you bro

  • @thefinalfit
    @thefinalfit Рік тому

    Someone trade said - GOAT of DSA
    King of Graphs ❤

  • @shivanshumishra3305
    @shivanshumishra3305 3 місяці тому

    Hi bro,
    Your videos are very helpful and love the way you make this easier to understand. Just one suggestion it would be great if at the end of the video you show dry run of Java program

  • @gauravbanerjee2898
    @gauravbanerjee2898 3 місяці тому +1

    Thanks a lot bhaiya ❤❤

  • @GeniusOG
    @GeniusOG Рік тому +2

    Easy and Best Explaination As Always

  • @aizad786iqbal
    @aizad786iqbal 3 місяці тому +1

    i will start from scract someday and do this using bellman ford also

  • @oqant0424
    @oqant0424 Рік тому +2

    u made it a cakewalk!
    thanks❤

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 3 місяці тому +2

    NICE SUPER EXCELLENT MOTIVATED

  • @tutuimam3381
    @tutuimam3381 Рік тому +2

    Amazing explanation👍

  • @vishwasjain6993
    @vishwasjain6993 3 місяці тому +1

    great explanation bhaiya .

  • @UtkarshPatel-v9o
    @UtkarshPatel-v9o Рік тому +1

    very good explanation

  • @satvikagrawal8334
    @satvikagrawal8334 3 місяці тому

    a slight overlook, since this is an undirected graph we also need to store the probability of going from v to u and not just u to v so we need to add both of these while creating the adjacency map
    adj[u].push_back({v, prob});
    adj[v].push_back({u, prob});

  • @neelx9437
    @neelx9437 Рік тому +3

    Java code for this ques-
    class Pair{
    int node;
    double prob;
    Pair(int node,double prob){
    this.node=node;
    this.prob=prob;
    }
    }
    class Solution {
    public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) {
    List adj=new ArrayList();
    for(int i=0;i Double.compare(b.prob,a.prob));
    q.offer(new Pair(start,1.0));

    while(!q.isEmpty()){
    Pair temp=q.poll();
    int u=temp.node;
    double upb=temp.prob;
    if(u==end) return upb;
    for(Pair it:adj.get(u)){
    int v=it.node;
    double vpb=it.prob;
    if(upb*vpb>prob[v]){
    prob[v]=upb*vpb;
    q.offer(new Pair(v,prob[v]));
    }
    }
    }
    return 0.0;
    }
    }

  • @sauravbiswajit8091
    @sauravbiswajit8091 Рік тому +1

    Yuppp...thanks a lot

  • @piyushmalviya4608
    @piyushmalviya4608 3 місяці тому +1

    watched only 6 min of video and solved it

  • @sudesh6807
    @sudesh6807 3 місяці тому

    For the same code in kotlin it is throwing Time Limit exceeded. it was failing for N size of 1000. Maybe they have added new test case now. Will have to cache the results

  • @abhinay.k
    @abhinay.k 3 місяці тому +1

    thank you

  • @Rajat_maurya
    @Rajat_maurya Рік тому +1

    those who know dijkstra its easy for them

  • @AlishaKhan-ww3io
    @AlishaKhan-ww3io Рік тому

    Awesome ❤

  • @wearevacationuncoverers
    @wearevacationuncoverers Рік тому

    Please post today's POTD - 864. Shortest Path to Get All Keys

  • @vetlakvsatyanarayana746
    @vetlakvsatyanarayana746 Рік тому

    Why using Queue results in lesser runtime when compared to maxheap?

    • @vibhosharma9487
      @vibhosharma9487 3 місяці тому +1

      to maintain maxheap it takes logn time.

  • @level_up.1908
    @level_up.1908 Рік тому +1

    bhai good explain ,i want to also make such videos with clarity ,can i get a chance to learn from u ,how u do that

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +1

      Thank you😊
      For making the video, I don’t have any fancy equipment. I just do screen recording of my ipad and write on it.

    • @level_up.1908
      @level_up.1908 Рік тому +1

      @@codestorywithMIK bhai aap editing nahi krte kya ,kyuki aese toh sahi se video nahi aati 🥲

    • @level_up.1908
      @level_up.1908 Рік тому

      woh janna hn kese krte hon

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +3

      @level_up.1908 As of now, I only record simply and upload it.
      Soon i will buy some equipments for good editing and quality.
      Hope to help you all in better way

  • @The-fc1fi
    @The-fc1fi Рік тому

    Gives your codeforces and leetcode profile link

  • @codeandtalk6
    @codeandtalk6 Рік тому

  • @mileshsoni5016
    @mileshsoni5016 Рік тому

    bhai why can't we use dfs?

    • @mileshsoni5016
      @mileshsoni5016 Рік тому

      here is the code
      class Solution {
      public:
      double dfs(vector& list, int sv, int end, vector& visited){
      if(sv == end){
      return 1;
      }
      visited[sv] = true;
      double answer = 0;
      for(int i=0; i

    • @SnehaR380
      @SnehaR380 6 місяців тому

      @@mileshsoni5016 COZ IT WILL GIVE TLE
      class Solution {
      public:
      void dfs(unordered_map& adj, vector& visited, double& maxi, double ans, int u, int c) {
      if(u == c) {
      maxi = max(maxi, ans);
      return;
      }
      visited[u] = true;
      for(auto& x : adj[u]) {
      int k = x.first;
      double l = x.second;
      if(!visited[k]) {
      dfs(adj, visited, maxi, ans * l, k, c);
      }
      }
      visited[u] = false; // backtrack to allow other paths
      }
      double maxProbability(int n, vector& a, vector& p, int s, int e) {
      unordered_map adj;
      for(int i = 0; i < a.size(); i++) {
      int u = a[i][0];
      int v = a[i][1];
      double d = p[i];
      adj[u].push_back({v, d});
      adj[v].push_back({u, d});
      }
      vector visited(n, false);
      double maxi = 0.0;
      double ans = 1.0;
      dfs(adj, visited, maxi, ans, s, e);
      return maxi;
      }
      };
      SEE IT GAVE TLE

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 3 місяці тому

    no using PriorityQueue Solution.
    public double maxProbability(int n,int[][]edges,double[]succProb,int star,int end){
    double[]maxProb=new double[n];
    maxProb[start]=1.0;
    for(int i=0;imaxProb[src]){
    maxProb[src]=maxProb[des]*prob;
    flag=true;
    }
    }
    if(flag==false) break;
    }
    return maxProb[end];
    }
    🎉❤

  • @iamnoob7593
    @iamnoob7593 2 місяці тому +1

    Thank you