787. Cheapest Flights Within K Stops | Dijkstras | BFS | Complete Internal Working

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • In this video, I'll talk about how to solve Leetcode 787. Cheapest Flights Within K Stops | Dijkstras | BFS
    Learn Dijkstras - • 2642. Design Graph Wit...
    Learn BFS - • G-05 Breadth First Sea...
    Checkout DSA-169 Series: • Aryan DSA-169 Series |...
    100Days 100k Placements: • 100 Days 100K Placement
    Let's Connect:
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / ez.pz.dsa
    📱Telegram : t.me/aryan_mittal_group
    🤖 Github: github.com/aryan-0077
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    0:00 - What to Expect
    1:15 - Problem Explanation
    2:48 - Dijkstras Intuition
    6:52 - Why Normal Dijkstras can be Wrong (Dry Run)
    11:22 - Modified Dijkstras (Dry Run)
    22:28 - Dijkstras Code Explanation
    25:00 - Complexity of Modified Dijkstras
    27:08 - BFS Intuition
    31:22 - BFS Dry Run
    32:39 - BFS Code Explanation
    35:03 - BFS Complexity Explanation
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 28

  • @ARYANMITTAL
    @ARYANMITTAL  Před 5 měsíci +13

    Sorry guys, video is a bit late today, it took some time to make notes for this one 🫡📝!!

    • @harshal8781
      @harshal8781 Před 5 měsíci

      Kaar diya maaf 😅

    • @rajrajesh1669
      @rajrajesh1669 Před 5 měsíci +1

      It's alright bro, we are always grateful for your work and contribution to the coding community...

    • @ARYANMITTAL
      @ARYANMITTAL  Před 5 měsíci

      😂😂

    • @ARYANMITTAL
      @ARYANMITTAL  Před 5 měsíci

      🫂🫂

  • @rajrajesh1669
    @rajrajesh1669 Před 5 měsíci +5

    Man, There's no way this problem can actually be solved using dijkstra's algo😢...
    Such a beautiful explanation as gulab jamun for the dijkstra's algo approach.
    Thanks a lot...
    My only qtn rn is How did you came up with this solution bro?😂

    • @ARYANMITTAL
      @ARYANMITTAL  Před 5 měsíci +2

      Glad you loved Rajesh ❤️❤️

  • @shashanksingh3008
    @shashanksingh3008 Před měsícem

    Dem how do you always know what I am gonna try and explain the correct way to overcome the problems i encountered after hours of head banging.

  • @nikhilbabar2226
    @nikhilbabar2226 Před 5 měsíci +3

    Great video !, one approach which I tried was dfs + dp

  • @surajshekhar17
    @surajshekhar17 Před 5 měsíci +3

    8:49

  • @Anonymous-lb6mc
    @Anonymous-lb6mc Před 5 měsíci

    Great !! Thanks man!!

  • @hrithikkumar7974
    @hrithikkumar7974 Před 5 měsíci

    why is the time complexity of bfs solution O(n+e.k)?
    if n=99 and k=100 then every node can be visited 2^(flights.size()) time right?

  • @krishnasharma657
    @krishnasharma657 Před 4 měsíci +2

    Dijkstra gives tle 😅

  • @varadv3
    @varadv3 Před 5 měsíci +2

    8:50 "maksad nahi bhulna guys" 🤣

  • @ABHAYKUMAR-kt3ug
    @ABHAYKUMAR-kt3ug Před 5 měsíci +1

    Aap pehle ki tarah video vale notes ki pdf description me daal diya karo plz

  • @sumitrajan9030
    @sumitrajan9030 Před 5 měsíci

    No problem bro 🤜

  • @fraserdab
    @fraserdab Před 5 měsíci

    If u said "smash the like button" at 35:40 then the like button would've glown, just a fun thing, thanks for the video

  • @chickukoshti3741
    @chickukoshti3741 Před 5 měsíci

    not getting

  • @gourabchatterjee1778
    @gourabchatterjee1778 Před 5 měsíci

    Just to mention your dijkstra's code is wrong..We cannot return distance when node==dst inside the loop....You messed up dijkstra's and bfs together

    • @ARYANMITTAL
      @ARYANMITTAL  Před 5 měsíci +2

      Bro, I mentioned in video 6 times how it works, still you have a comment like this 🫠, and then people say, why i repeat stuff 🤣

    • @gourabchatterjee1778
      @gourabchatterjee1778 Před 5 měsíci

      @@ARYANMITTAL Well you can actually repeat it for the 7th time but the code would still be wrong

    • @AkashKumar-bm4py
      @AkashKumar-bm4py Před 5 měsíci

      @@ARYANMITTAL Bro but it will search for other possible solutions as well ,which might be more optimum solution. In the example you just explored one path .

    • @shashanksingh3008
      @shashanksingh3008 Před měsícem

      @@gourabchatterjee1778 bro the code is completely right !! You can definitely return the distance because priority queue would have already set the lowest distance and lowest step which we actually want.