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.
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!
@@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?
This is the only explanation that has actually made sense to me for this problem, thank you
Glad it made sense Gerry!
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.
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.
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!
@@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?
@@ajaysrinivas2814 Ah yes good spot, there is a slight mistake there!
can anyone explain arr index arr[5] why we put 1 not iterate to check all 1,2,5?
I would not be able to come up with this solution in an interview