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

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น • 56

  • @tauquirahmed1879
    @tauquirahmed1879 ปีที่แล้ว +27

    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 2 หลายเดือนก่อน

      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 - th-cam.com/video/xQ3vjWwFRuI/w-d-xo.html
    Thank you to all of you for your kind reviews and comments❣

  • @thekindspill
    @thekindspill ปีที่แล้ว +2

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

  • @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.

  • @Still_standing418
    @Still_standing418 ปีที่แล้ว +2

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

  • @aws_handles
    @aws_handles 2 หลายเดือนก่อน +3

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

  • @rohan8758
    @rohan8758 2 หลายเดือนก่อน +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

  • @ugcwithaddi
    @ugcwithaddi ปีที่แล้ว

    Someone trade said - GOAT of DSA
    King of Graphs ❤

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 2 หลายเดือนก่อน +2

    NICE SUPER EXCELLENT MOTIVATED

  • @shivanshumishra3305
    @shivanshumishra3305 2 หลายเดือนก่อน

    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

  • @GeniusOG
    @GeniusOG ปีที่แล้ว +2

    Easy and Best Explaination As Always

  • @vishwasjain6993
    @vishwasjain6993 2 หลายเดือนก่อน +1

    great explanation bhaiya .

  • @gauravbanerjee2898
    @gauravbanerjee2898 2 หลายเดือนก่อน +1

    Thanks a lot bhaiya ❤❤

  • @aizad786iqbal
    @aizad786iqbal 2 หลายเดือนก่อน +1

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

  • @tutuimam3381
    @tutuimam3381 ปีที่แล้ว +2

    Amazing explanation👍

  • @oqant0424
    @oqant0424 ปีที่แล้ว +2

    u made it a cakewalk!
    thanks❤

  • @UtkarshPatel-v9o
    @UtkarshPatel-v9o ปีที่แล้ว +1

    very good explanation

  • @sudesh6807
    @sudesh6807 2 หลายเดือนก่อน

    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

  • @piyushmalviya4608
    @piyushmalviya4608 2 หลายเดือนก่อน +1

    watched only 6 min of video and solved it

  • @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;
    }
    }

  • @abhinay.k
    @abhinay.k 2 หลายเดือนก่อน +1

    thank you

  • @satvikagrawal8334
    @satvikagrawal8334 2 หลายเดือนก่อน

    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});

  • @sauravbiswajit8091
    @sauravbiswajit8091 ปีที่แล้ว +1

    Yuppp...thanks a lot

  • @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

  • @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 2 หลายเดือนก่อน +1

      to maintain maxheap it takes logn time.

  • @Rajat_maurya
    @Rajat_maurya ปีที่แล้ว +1

    those who know dijkstra its easy for them

  • @The-fc1fi
    @The-fc1fi ปีที่แล้ว

    Gives your codeforces and leetcode profile link

  • @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 5 หลายเดือนก่อน

      @@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

  • @codeandtalk6
    @codeandtalk6 ปีที่แล้ว

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 2 หลายเดือนก่อน

    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 หลายเดือนก่อน +1

    Thank you