Coin Change Top down dynamic programming

  Рет қаралды 50,266

Tushar Roy - Coding Made Simple

Tushar Roy - Coding Made Simple

Күн бұрын

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
@mukundsridhar4250
@mukundsridhar4250 7 жыл бұрын
Thanks Tushar for all your videos. You have enrichced the lives of so many people.
@mojahidislam9717
@mojahidislam9717 9 жыл бұрын
it's great that you r explaining the code too ....please keep doing that...your efforts is seriously helping many students like me.....
@stephengardner5746
@stephengardner5746 7 жыл бұрын
This is the best explanation I've seen. Thanx
@nemanjastankovic941
@nemanjastankovic941 9 жыл бұрын
great explination. i like the way you structure your lectures: problem definition->example->code. best regards from serbia
@khumoyunakhmedov4562
@khumoyunakhmedov4562 8 жыл бұрын
thanks very much brother. You threw a shiny light on my understanding of this problem
@samuelmoon3739
@samuelmoon3739 5 жыл бұрын
Clear and concise explanation. Thank you
@debiduttamishra4760
@debiduttamishra4760 9 жыл бұрын
As always.. Brilliant explanation Tushar.
@swagatikachoudhury2115
@swagatikachoudhury2115 3 жыл бұрын
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
@PiggyGirlBeauty
@PiggyGirlBeauty 9 жыл бұрын
Thanks for your vids!
@AmritpalSingh-gm1eu
@AmritpalSingh-gm1eu 8 жыл бұрын
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-gm1eu
@AmritpalSingh-gm1eu 8 жыл бұрын
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
@iamdipankarj
@iamdipankarj 9 жыл бұрын
Please make a Top down approach for the knapsack problem.
@AMAR18MEHTA
@AMAR18MEHTA 9 жыл бұрын
Hi, which video have you discussed bottom-up approach for the same problem, the one mentioned at 0:14?
@SamVillage
@SamVillage 2 жыл бұрын
Bottom-up dynamic programming kzbin.info/www/bejne/j2G9on6midSHn8U
@moamenahmed7543
@moamenahmed7543 6 жыл бұрын
What to do if I want to print the values which form the minimum no. of coins ? (With Top Down Approach)
@slmnkh
@slmnkh 9 жыл бұрын
great video! thanks!
@kartikayy
@kartikayy 9 жыл бұрын
Always prefered watching your tutorial videos... A very nice explaination Indeed When Trie tutorial will be coming??
@kartikayy
@kartikayy 9 жыл бұрын
Dictionary thing . and How it is implemented
@jlecampana
@jlecampana 7 жыл бұрын
Are all dynamic programming problems as difficult as this one?
@komalsoni1722
@komalsoni1722 7 жыл бұрын
lol this isn't difficult at all
@Amanyadav-ec3hn
@Amanyadav-ec3hn 5 жыл бұрын
Thanks a lot!!!
@kobe2453
@kobe2453 9 жыл бұрын
can you reduce the sound from keyboard
@theOceanMoon
@theOceanMoon 9 жыл бұрын
Great explanation but bottom up much simpler
@tonyjiang4991
@tonyjiang4991 4 жыл бұрын
He has a bottom up solution in another vedio.
@1clutchx675
@1clutchx675 3 жыл бұрын
why 14 disliked i mean dislikers are blind or def or may be have some mental problems may be they hold there device upside down.
Text Justification Dynamic Programming
15:31
Tushar Roy - Coding Made Simple
Рет қаралды 144 М.
Coin Change - Dynamic Programming Bottom Up - Leetcode 322
19:23
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Minimum Coins | Greedy Algorithms
10:22
take U forward
Рет қаралды 117 М.
Bottom Up vs Top Down Dynamic Programming vs Recursion | Fibonacci Sequence
7:26
Algorithms With Brenton
Рет қаралды 18 М.
0/1 Knapsack Problem Top Down Dynamic Programming
15:45
Tushar Roy - Coding Made Simple
Рет қаралды 54 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 18 М.
The Change Making Problem - Fewest Coins To Make Change Dynamic Programming
23:12
Maximum Sum Increasing Subsequence Dynamic Programming
8:30
Tushar Roy - Coding Made Simple
Рет қаралды 82 М.
Coin Change
10:16
Kevin Naughton Jr.
Рет қаралды 154 М.
R5. Dynamic Programming
52:03
MIT OpenCourseWare
Рет қаралды 112 М.