3418. Maximum Amount of Money Robot Can Earn | DP on Grids | Top Down Approach

Поделиться
HTML-код
  • Опубликовано: 2 фев 2025

Комментарии • 23

  • @kbcoder3734
    @kbcoder3734 22 дня назад +3

    Superb solution, I spent more than 1 hour on this problem during the contest while using 2-d DP.

  • @shauryatomer1058
    @shauryatomer1058 22 дня назад +1

    thanks for the great explanation, was able to come with complete solution, only thing left was didn't think separate base case would be required for i = m - 1 && j = n - 1.

  • @whyyshivam
    @whyyshivam 22 дня назад +1

    Another approach I thought of is : Calculate the total sum from (0,0) till (m−1,n−1), including negative values. During the traversal, track the two smallest (most negative) values. In the final answer, add the absolute values of these two smallest negatives to the total sum.
    Is this approach correct?

    • @kumkumslab5811
      @kumkumslab5811 19 дней назад

      no because you can't track which path you have selected so might be possible that 2 min elements are not the part of that path

  • @DarkDragon-bz6qp
    @DarkDragon-bz6qp 22 дня назад +1

    Thanks Great explanation..For interviews if i explain till memoization will it be enough?or i need to use bottom up approach?

    • @25-cse-csmohitkumarmandal59
      @25-cse-csmohitkumarmandal59 21 день назад

      If you able to solve memorization, you will able to solve bottom up already (once watch Love Babbar 's DP series)
      (If q. Is easy-moderate)

    • @DarkDragon-bz6qp
      @DarkDragon-bz6qp 21 день назад

      ​@@25-cse-csmohitkumarmandal59okk

  • @aryavyadav9345
    @aryavyadav9345 22 дня назад

    Was able to solve this question during the contest thankfully 😊

    • @NeelakshiSachdeva
      @NeelakshiSachdeva 20 дней назад

      Can I do dp without doing recursion?? Actually somebody told me to do recursion first as dp follows but even after spending 2 weeks I'm not getting recursion totally. Can u pls guide if dp can be done independently.or not?

    • @aryavyadav9345
      @aryavyadav9345 18 дней назад

      @@NeelakshiSachdeva DP can be done without recursion, that method is called tabulation where loops are involved. However, I highly suggest you to follow through learning recursion. Try doing striver's SDE sheet's recursion questions and watch his vids on those questions. You can also check out Love Babbar's C++ course. Recursion is very important as it has applications in higher data structures like trees and graphs. Also , an update now that the rating has been updated on leetcode. It turns out leetcode rejected my solution on this question since it gave TLE on the 577 test case.

  • @kodurisaivishnu4916
    @kodurisaivishnu4916 22 дня назад +1

    i have got an idea to solve this problem but ,Failed to handle the Base case.
    Does AnyOne With same problem ?

    • @BruceWayne-lm6xt
      @BruceWayne-lm6xt 21 день назад

      yes
      me toooo

    • @dipanshubose-u9b
      @dipanshubose-u9b 20 дней назад

      Yeah just forgot the case where theres is a robber at the destination cell

  • @Its_Shubham_Negi
    @Its_Shubham_Negi 22 дня назад

    Thanks ❤

  • @KedarBhawthankar
    @KedarBhawthankar 20 дней назад

    you explain very well but i dont understand

  • @DarkDragon-bz6qp
    @DarkDragon-bz6qp 22 дня назад +1

    Found this question tough

  • @staywithmeforever
    @staywithmeforever 16 дней назад

    Atmost 2 cells is the worse

  • @nikhilprakash729
    @nikhilprakash729 22 дня назад

    nice..