Dungeon Game (LeetCode) | Dynamic Programming Explanation

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • Link to the Code: gist.github.com/JyotinderSing...
    Link to the question: leetcode.com/problems/dungeon...
    Link to my GitHub: github.com/JyotinderSingh
    Link to my Website: jyotindersingh.com/
    Timestamps:
    00:00 - Problem Explanation
    06:20 - Algorithm Walkthrough
    19:21 - Coding Walkthrough
    _______________________________________
    Some great channels to learn more:
    Tushar Roy: / tusharroy2525
    Errichto: / @errichto
    Nick White: / @nickwhite
    Kevin Naughton Jr: / @kevinnaughtonjr
  • Věda a technologie

Komentáře • 18

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

    gone through 3-4 videos but this was the best explanation. Thank you.

  • @divyatyagi2967
    @divyatyagi2967 Před 3 lety +2

    I have watched all videos there is to watch for this question, but only could understand your code walkthrough; thank you so much :))

    • @JyotinderSingh
      @JyotinderSingh  Před 3 lety

      I'm really glad you found this video useful! Be sure to subscribe for future content!

  • @nmnjn
    @nmnjn Před 4 lety +4

    this is gonna change the game 💪🏻

  • @VishalSanghai
    @VishalSanghai Před 4 lety +3

    Very good explaination, I was doing the mistake of going top-down, without thinking that values at i, j depend on the future values.
    Thanks!

    • @JyotinderSingh
      @JyotinderSingh  Před 4 lety +1

      Glad I could help! Be sure to subscribe for all the future content! ♥

  • @shreyanshshrivastava5395
    @shreyanshshrivastava5395 Před 4 lety +1

    Very nicely explained :D , didn't understand this concept from other videos.
    Also it was nice to see that you have timestamps as well in the video, that helped :)

    • @JyotinderSingh
      @JyotinderSingh  Před 4 lety +1

      Thank you so much! I'm glad you found this useful :) Subscribe for more upcoming videos!

  • @pavanala2200
    @pavanala2200 Před 3 lety +1

    Very helpful.. do more such videos❤️❤️

    • @JyotinderSingh
      @JyotinderSingh  Před 3 lety

      Yes! More content coming up! Be sure to subscribe!

  • @cicciopasticcio8469
    @cicciopasticcio8469 Před 4 lety +1

    Thanks, excellent explanation

  • @dangerousdookie8822
    @dangerousdookie8822 Před 4 lety +1

    Very well explained

  • @yudilokhande8915
    @yudilokhande8915 Před 3 lety +1

    Loved it!

  • @thiccphone1166
    @thiccphone1166 Před 4 měsíci

    Why would you want the minimum health at the end?
    I would want maximum health especially if you can carry health over to the next floor. TBH, wasn't really paying attention and you may have explained it but I don't get what you mean by "wasting health" since you aren't technically wasting anything since if the goal is only to reach (2,2) from (0,0) as long as you get to the location then the optimal solution is taking less steps. Since both solutions are equal, except one solution results in having more health at the end, it would be safe to assume that MORE health at the end is better rather than having the minimum.
    Having the maximum health means you will be prepared for the future, while having the minimum means you can only do the single task.
    So if the rule was to get there with the fewest steps, then health is irrelevant outside of being alive upon reaching the destination.
    If the rule was to get there before the princess's health reaches 0, say after every step she loses health and has a number of health points, the optimal solution would be to get as much health for the knight as possible and the princess has the minimum required to reach the goal.
    Given that the only rule is to reach the princess without dying then there are two solutions.
    If the question was what's the minimum health required by a knight to reach the princess then the optimal solution is still Down-Down-Right-Right as the minimum health require is 6, not 7.
    At the same time, my knight would be stronger by the time I reach the princess and your knight would be the weakest. My underdog knight could continue adventuring.