Coin Change - LeetCode 322 - JavaScript

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

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

  • @gerryramosftw
    @gerryramosftw ปีที่แล้ว +3

    This is the only explanation that has actually made sense to me for this problem, thank you

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

      Glad it made sense Gerry!

  • @fabricator.cap.hill.seattle
    @fabricator.cap.hill.seattle 6 หลายเดือนก่อน

    I'm new to dynamic programming. I lost track around 3:40. I'll continue watching the vid, and hopefully in the future it's better able to solve DP programs.

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

    At 7:07, when we chose the coin 1, the remaining coins needed is dp[6] that is 2. So it should have been 1 + 2 = 3 when the first coin is selected.

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

      Work through this step by step:
      1. We have coins 1, 2 and 5
      2. We take the first coin of 1
      3. We need another coin from step 1 that will make a total of 6 when added with the original 1 we took
      4. That coin is 5, so we take 5
      5. We have made 6 with 2 coins, 1 and 5
      So the answers is 2 when we take coin 1. Hope this helps!

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

      @@AlgoJS No I mean for dp[7] when you take the first coin 1. The minimum coins needed is 1 + dp[6] i.e., 1 + 2 = 3.
      It should have been 1 + dp[7 - 1], but I guess you mistook it to be 1 + dp[7 - 6], may be the flow threw it off or something idk. Is that right?

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

      @@ajaysrinivas2814 Ah yes good spot, there is a slight mistake there!

  • @techycode2217
    @techycode2217 3 หลายเดือนก่อน

    can anyone explain arr index arr[5] why we put 1 not iterate to check all 1,2,5?

  • @joemart6887
    @joemart6887 4 หลายเดือนก่อน

    I would not be able to come up with this solution in an interview