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

Sdílet
Vložit
  • čas přidán 26. 06. 2023
  • *******Watch my Dijkstra's Algorithm Video and copy paste the same code with slight variation - • Dijkstra's Algorithm |...
    This is the 30th Video on our Graphs Playlist.
    In this video we will try to solve a very good Graph Problem "Path with Maximum Probability " (Leetcode - 1514)
    This is nothing but just a simple variation of Dijkstra's Algorithm.
    I am promising you, this problem will become easy once you are done with this video.
    If you have been following my "Graph Concepts & Qns" playlist , then these Qns will become very easy. Find the Link for that below.
    We will do live coding after explanation and see if we are able to pass all the test cases.
    Problem Name : Path with Maximum Probability
    Company Tags : GOOGLE
    My solutions on Github : github.com/MAZHARMIK/Intervie...
    Leetcode Link : leetcode.com/problems/path-wi...
    My DP Concepts Playlist : • Roadmap for DP | How t...
    My Graph Concepts Playlist : • Graph Concepts & Qns -...
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : / @codestorywithmik
    Instagram : / codestorywithmik
    Facebook : / 100090524295846
    ╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips
    #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook

Komentáře • 41

  • @tauquirahmed1879
    @tauquirahmed1879 Před rokem +10

    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  Před rokem +1

      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 Před rokem +1

      @@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  Před rokem +4

      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 Před rokem

      @@codestorywithMIK ❣️

  • @floatingpoint7629
    @floatingpoint7629 Před rokem +5

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

  • @souravjoshi2293
    @souravjoshi2293 Před rokem +1

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

  • @wearevacationuncoverers

    Literally no one teaches like you bro

  • @Thriftinghai
    @Thriftinghai Před rokem +2

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

  • @user-vd2jc7lm3h
    @user-vd2jc7lm3h Před rokem +1

    very good explanation

  • @Still_standing418
    @Still_standing418 Před rokem +2

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

  • @sauravbiswajit8091
    @sauravbiswajit8091 Před rokem +1

    Yuppp...thanks a lot

  • @codestorywithMIK
    @codestorywithMIK  Před rokem +4

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

  • @tutuimam3381
    @tutuimam3381 Před rokem +2

    Amazing explanation👍

  • @AlishaKhan-ww3io
    @AlishaKhan-ww3io Před rokem

    Awesome ❤

  • @ugcwithaddi
    @ugcwithaddi Před rokem

    Someone trade said - GOAT of DSA
    King of Graphs ❤

  • @GeniusOG
    @GeniusOG Před rokem +2

    Easy and Best Explaination As Always

  • @oqant0424
    @oqant0424 Před rokem +1

    u made it a cakewalk!
    thanks❤

  • @wearevacationuncoverers

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

  • @Rajat_maurya
    @Rajat_maurya Před rokem +1

    those who know dijkstra its easy for them

  • @codeandtalk6
    @codeandtalk6 Před rokem

  • @vetlakvsatyanarayana746

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

  • @level_up.1908
    @level_up.1908 Před rokem +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  Před rokem +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 Před rokem +1

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

    • @level_up.1908
      @level_up.1908 Před rokem

      woh janna hn kese krte hon

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +2

      @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 Před rokem

    Gives your codeforces and leetcode profile link

  • @neelx9437
    @neelx9437 Před rokem +2

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

  • @mileshsoni5016
    @mileshsoni5016 Před rokem

    bhai why can't we use dfs?

    • @mileshsoni5016
      @mileshsoni5016 Před rokem

      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 Před 2 měsíci

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