Given a total and coins of certain denominations with infinite supply, how many minimum number of coins would it take to form this total. / tusharroy25 github.com/mis... github.com/mis...
Пікірлер: 28
@mukundsridhar42507 жыл бұрын
Thanks Tushar for all your videos. You have enrichced the lives of so many people.
@mojahidislam97179 жыл бұрын
it's great that you r explaining the code too ....please keep doing that...your efforts is seriously helping many students like me.....
@stephengardner57467 жыл бұрын
This is the best explanation I've seen. Thanx
@nemanjastankovic9419 жыл бұрын
great explination. i like the way you structure your lectures: problem definition->example->code. best regards from serbia
@khumoyunakhmedov45628 жыл бұрын
thanks very much brother. You threw a shiny light on my understanding of this problem
@samuelmoon37395 жыл бұрын
Clear and concise explanation. Thank you
@debiduttamishra47609 жыл бұрын
As always.. Brilliant explanation Tushar.
@swagatikachoudhury21153 жыл бұрын
Same solution but little change: public static int coinChange(int[]coins,int sum, HashMap map) { if(sum==0) return 0; if(map.get(sum)!=null) return map.get(sum); int min=Integer.MAX_VALUE; for(int i=0;isum) continue; int num=coinChange(coins,sum-coins[i],map); if(num
@PiggyGirlBeauty9 жыл бұрын
Thanks for your vids!
@AmritpalSingh-gm1eu8 жыл бұрын
Hi Tushar, First of all, Great Explanation of the top down approach. However, I wanted to make one point regarding the Time complexity of this algorithm. As per the explanation, it is M X N, where M is the total that we are trying to achieve (5 in this example) and N is the number of coins (3, in this case). So M X N is achieved as we get down to 5 levels of recursion and in each recursive iteration, we have a for loop of 3 iterations, hence 5 X 3. However, in this example, the smallest denomination of coins is 1 and hence each recursive call is stepped down by reducing 1 (equivalent to the total - coins[i]), so it takes 5 recursive iterations. In case the smallest denomination of coin is not 1 and a bigger number, say 2 or 4, the time complexity is further reduced to (M/smallest coin X N). Please let me know if this makes sense.
@AmritpalSingh-gm1eu8 жыл бұрын
Also, After going through the video explanation and the code at the end, it seems they are out of sync. In the explanation, it seems that we are first calling the recursion and after the recursion returns we loop through each coin for that specific balance. However, in the code, the recursion is being called inside the loop, thus generating the sub trees for each coin. My understanding can be wrong, but I created my quick and dirty version according to the explanation. I would appreciate if you could comment on this. rextester.com/SLUGL76503
@iamdipankarj9 жыл бұрын
Please make a Top down approach for the knapsack problem.
@AMAR18MEHTA9 жыл бұрын
Hi, which video have you discussed bottom-up approach for the same problem, the one mentioned at 0:14?