Lecture 104: Minimum Number of Coins || DP Series

  Рет қаралды 153,163

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

Пікірлер: 237
@CodeHelp
@CodeHelp 2 жыл бұрын
Correction: In the Recursion + Memoisation approach, we are TLE due to not changing the function call os solveRec to solveMem in "solveMem" function, change that to get rid of TLE.
@vedprakash3621
@vedprakash3621 2 жыл бұрын
Atleast someone is here to help and correct us. Thank you bhaiya
@pranavdamedhar5375
@pranavdamedhar5375 2 жыл бұрын
yes bhaiiya ..ek request this bas dp ke liye aap thoda jyada page pe samjhane ka try kro n...drct code krne se samjh nhi ata easily
@iamsuryakant
@iamsuryakant 2 жыл бұрын
In solveMem function.. you return mini. it should be return dp[x].
@ayushraj6525
@ayushraj6525 2 жыл бұрын
@@iamsuryakant Exactly!
@TechCluesByAbsek
@TechCluesByAbsek 2 жыл бұрын
Dear bhaiya, your all videos are awesome, **** humble feedback what I felt**** >> feel nhii aaya to convert recursive to bottom-up, it needs more explanation.(what I feel). everything else is top class.
@akshayiyer2014
@akshayiyer2014 2 жыл бұрын
This series is very helpful in understanding dynamic programming. Last month i gave close to 40+ interviews and saw product based companies like Walmart, DP World, Zoomcar, Swiggy, MMT and some startups asking DP or heap related questions. LeetCode and your channel has helped a lot in brushing my dsa skills.
@keshavgupta383
@keshavgupta383 2 жыл бұрын
last 2 dp series lecture was amazing but this lecture had some problem in understanding if you could dry run that part would be grateful
@TechCluesByAbsek
@TechCluesByAbsek 2 жыл бұрын
Dear bhaiya, your all videos are awesome, ** humble feedback what I felt** >> feel nhii aaya to convert recursive to bottom-up, it needs more explanation.(what I feel). everything else is top class.
@laxmankumawat6728
@laxmankumawat6728 2 жыл бұрын
Dry run karke pura bta dete hai tab maaza aata hai Base case jab rich ho jata hai toh badh me call kaise uper aati hai include all questions this make this series more best
@sourabhshubham2910
@sourabhshubham2910 2 жыл бұрын
Aap jis tareeke se padha rhe ho na utna hi kaafi hai, multiple approach , aur padhaane ka tareeka , brilliant hai, Thanks a lot for this series :)
@kungagyaltsenlachungpa8915
@kungagyaltsenlachungpa8915 2 жыл бұрын
last 2 dp series lecture was amazing but this lectur had some problem in understanding the mimimum coin flow if you could dry run that part would be grateful.Apart from that dp series blockbuster ha.
@codexamofficial
@codexamofficial 2 жыл бұрын
Memorization solves - 14:42 Mistake one - call solveMem function line 32 2nd Mistake pass dp line 32 .... thanks for making this great playlist int solveMem(vector &num , int x , vector&dp) { // Base Case if(x == 0) return 0; if(x < 0) return INT_MAX; // dp case if(dp[x] != -1) return dp[x]; // Recursive case int mini = INT_MAX; for(int i = 0; i < num.size(); ++i) { int ans = solveMem(num , x-num[i] , dp); if(ans != INT_MAX) mini = min(mini , ans+1); } // Recrence Reletion dp[x] = mini; return mini; } int minimumElements(vector &num, int x) { vectordp(x+1 , -1); int ans = solveMem(num , x , dp); if(ans == INT_MAX) return -1; else return ans; }
@naveenshukla3517
@naveenshukla3517 2 жыл бұрын
bhaiya out of above 104 lectures, this was the first lecture, jisme acche se smjh ni aya
@Kinggaming-hp3qp
@Kinggaming-hp3qp 2 жыл бұрын
guruji ko bhut bhut pyar and dil se aabhar.
@itspurelypassionate
@itspurelypassionate 2 жыл бұрын
for people who didn't understand tabulation method: i = coin number increasing form 1 to x. X is a target sum. num[j] gives coin value. Suppose that i = 2 and num[j] is also 2 then i - num[j] is zero. that means that we should add 1 to the amount of coins needed to get sum 0. We know that 0 coins are needed so (1 + 0) is 1 and minimum of dp[i] = min(dp[i], 1). if previously dp[i] value was MAX_VALUE than dp[2] will become 1. That means to get sum of 2 we need only 1 coin. Now iterate this through all the coins. U will get to know that 1 is the only correct answer (given 2 is present in "num" array. This is just an example. Feel free to ask any doubts)
@Nitian_Trader07
@Nitian_Trader07 Жыл бұрын
Bhaiya top down approach mai -> [14:47] yahan line no. 33 mai agar ans = INT_MAX aaya to wo if mai nahi jayega or direct mini jo ki INT_MAX hai wo return karega previous called function ko . To pichle function ko int_max hi milte rahega har baar kyuki minimum nikal hi nahi payega kyuki wo line no. 33 ke if condition ke karan . Koi to ho jo ise aache se samjhe pls bhaiyaa make correct that question for upcoming students.
@vishwamshourya3354
@vishwamshourya3354 2 жыл бұрын
sir if u will dry and run the code from the following problems, then it will be more helpful, facing a few problems in understanding the memoization approach of this problem..otherwise everything is perfect.
@luckydewangan5985
@luckydewangan5985 Жыл бұрын
Recursion+memoization vala approach is giving TLE because in solveMem fxn, the recursive relation is calling solveRec instead of solveMem. So effectively recursion+memoization+recursion ki khichdi ban ja rahi hai.😁😁
@tanayabiswas2417
@tanayabiswas2417 Жыл бұрын
exactly, i saw that as well
@therealartist9
@therealartist9 8 ай бұрын
bhai gend fatke char ho gyi lekin samajh ni aya
@inter3988
@inter3988 5 ай бұрын
@@therealartist9 kya nahi aya?
@keshavarya5999
@keshavarya5999 2 жыл бұрын
Best content on YT......Desi style
@NxNinjae
@NxNinjae 2 жыл бұрын
In your solveMemo function by mistake you used solveRec function that's why it is given TLE
@chandrabhanbahetwar9638
@chandrabhanbahetwar9638 2 жыл бұрын
This is one of the best dsa series in the you tube
@shreyashdubey5989
@shreyashdubey5989 2 жыл бұрын
Bhaiya Mauj Krdia, Lecture Completed !!! Great Explanation❤❤
@B-NikhilRichhariya
@B-NikhilRichhariya 11 ай бұрын
bohot achha lect tha bhaiya , is baar bhi poore code khud se ban gaye
@rohitrohra7553
@rohitrohra7553 Жыл бұрын
aapse seekh ke aza aata hai . Ekdum ghar jaisa
@RahulKumar-wt9qc
@RahulKumar-wt9qc 2 жыл бұрын
Jabardast explanation tha video me bhaiya
@rachit_joshi
@rachit_joshi 4 ай бұрын
Thank You So Much BHRATA SHREE !!!!!!!
@yashzawar7938
@yashzawar7938 2 жыл бұрын
took time to understood the solution but got it at the end as i tried to solve on my own with this logic
@tejalgarud7795
@tejalgarud7795 6 ай бұрын
One of the best learning platform, Thank You Bhaiyya!!
@abhasatin7300
@abhasatin7300 2 жыл бұрын
thanks bhaiya..after doing a dry run i was able to understand better. i wish the code explanation part came before running the code or while writing the code, easier to understand
@aaravkumar1308
@aaravkumar1308 2 жыл бұрын
bhaiya sab badiya chal rha hai .. U are making the best series .. Keep it up >>
@harishkumar2107
@harishkumar2107 2 жыл бұрын
What a consistent bhaiya you are best when it comes to coding 🔥🔥❣️❣️🤩
@yashh7449
@yashh7449 11 ай бұрын
Samajh aagya, aur maza bhi aagya ❤
@devangmishra4506
@devangmishra4506 2 жыл бұрын
gazzab ka lecture ...bhaiya opp
@haiderali0801
@haiderali0801 2 жыл бұрын
concept++ , bhaiya.
@anujonthemove
@anujonthemove Жыл бұрын
Explanation for recursive solution: Out of all possible combinations of the coins(which is what can be seen by the recursion tree), we have to find that 1 combination that makes up to the given amount using minimum number of coins. We are creating the variable `mini` which is initialized with max value, now it is getting updated every time during the recursion when it's previous value is more than the current value. Great explanation except for the glitch in the memoization part. Ek hi baat bolna hai: bhai samajh to acche se hindi me hi aata hai 😝
@ellis-pr7hh
@ellis-pr7hh Жыл бұрын
Last line is TRUE
@awesomepatt620
@awesomepatt620 2 жыл бұрын
Amazing concept bhaiya 🤩🤩
@anupamyadavnit7512
@anupamyadavnit7512 2 жыл бұрын
Thanks for this wonder full lectures 👍
@namyajain5927
@namyajain5927 Жыл бұрын
Can someone please explain why are we taking vectordp(x+1,INT_MAX ) in tabulation solution?
@Singh_Sahdev
@Singh_Sahdev 11 ай бұрын
Bro let you took -1 in dp array, then -1 would be itself a small value, We cannot find minimum no. Of coins hence we took INTMAX to minimize that value
@khushdevyogi6511
@khushdevyogi6511 Жыл бұрын
Bro you are most helpful at this time for me😍
@DeepakSingh-fd2ix
@DeepakSingh-fd2ix 2 жыл бұрын
sir uda diya yeh video toh 😶😶😶😶😶😶
@iteself_me
@iteself_me Жыл бұрын
186 ✅completed 👍Liked 09:29
@nishankdeep3084
@nishankdeep3084 2 жыл бұрын
thank you bhaiya bhaya poora ache se clear hua
@gopal_cse
@gopal_cse 8 ай бұрын
correction : include int solveRec(vector &num,vector &dp, int x){ if(x==0) return 0; if(x
@dewanshyadav6033
@dewanshyadav6033 2 жыл бұрын
❤️❤️❤️❤️❤️Bhaiyya this problem is solved using (Recursion+Memoization) method also ...you have not passed the dp array in recursive call => int ans = solveMem(num,x-num[i],dp); the why it was giving TLE error.... and Thank you bhaiya for this amazing lecture... ❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️
@shoumickbardhan1460
@shoumickbardhan1460 2 жыл бұрын
Well, I don't know about other platforms, but this by far the best DSA series ever made available on KZbin. That too even Free. Lots of Love Bhaiya😊😊
@sukhjitsingh959
@sukhjitsingh959 2 жыл бұрын
Yes here is problem to understand this code ..you are explain very fast about this code if you do little slow explain with dry run will be more cool thanks
@unknownuser6143
@unknownuser6143 Жыл бұрын
Awesome... very nice bhaiya...sab kuchh achchhe se samajh me aaya.
@aryankhatana7202
@aryankhatana7202 2 жыл бұрын
Namaste Bhaiya App ne jo solveMem function me for loop ke andar solveRec ko kol kiya hai isliye TLE aya hai agar app solveMem karogye to correct answer ayega Thankyou Bhaiya for this Amazing C++ With DSA Course
@jaisriRam4
@jaisriRam4 2 жыл бұрын
Great work bhaiya ji ❤️❤️❤️
@RaviRavi-kt9gt
@RaviRavi-kt9gt Жыл бұрын
Starting my dp series from today 😀
@kumarpawansahh
@kumarpawansahh 2 жыл бұрын
Dhanya ho gye bhaiya ji
@amishapandey6875
@amishapandey6875 Жыл бұрын
Thank you bhaiya!
@PRIYANSHUKUMAR-un9zu
@PRIYANSHUKUMAR-un9zu 2 жыл бұрын
Present bhaiya ❤✌🔥
@ramankr0022
@ramankr0022 Жыл бұрын
Very helpful. Thanks for uploading.
@AJEETSINGHYADAV-g1n
@AJEETSINGHYADAV-g1n Жыл бұрын
@CodeHelp Bhaiya we need to update the dp[x] in for loop itself for Memoisation Method for(int i=0;i
@yashraghuwanshi7710
@yashraghuwanshi7710 7 ай бұрын
sir please dry run each code it make it more easy to understand concept and it work as memorization for us
@antimr2808
@antimr2808 Жыл бұрын
thank you so much for creating this video
@Dhairyagaurr
@Dhairyagaurr 2 жыл бұрын
Babber bhaiya, Add these videos in DSA Series
@jaydwarkadhish959
@jaydwarkadhish959 2 жыл бұрын
Sir amazing video super
@codewith_ayushluthra5248
@codewith_ayushluthra5248 2 жыл бұрын
thank you bhaiya
@kalpi5023
@kalpi5023 3 ай бұрын
thank you bhaiyaa
@abhishekverma1528
@abhishekverma1528 2 жыл бұрын
consistency++
@pramantomar822
@pramantomar822 2 жыл бұрын
Loving the series ❤️❤️❤️❤️❤️❤️❤️❤️
@ayushgupta1881
@ayushgupta1881 Жыл бұрын
Thank you soo much bhaiya
@nikhilchopra8919
@nikhilchopra8919 Жыл бұрын
Bhaiya maza aa gaya +++++++++++++++++++++++++++++
@sarthaknikhal5540
@sarthaknikhal5540 2 жыл бұрын
Acha padha rahe ho
@itspurelypassionate
@itspurelypassionate 2 жыл бұрын
These series is so fuckn helpful. Thanks!!
@rahul191jain
@rahul191jain 2 жыл бұрын
I think memorization method is throwing tle because inside that method, recursive function of method 1 is being called rather than memorized one.
@gauravkumar3036
@gauravkumar3036 2 жыл бұрын
Nope
@vortexdeo4545
@vortexdeo4545 2 жыл бұрын
5:58 A lot going on in mind, Microsoft Resignation wale time ke aas paas ki video hai
@nayanjaiswal
@nayanjaiswal 2 жыл бұрын
Consistency op 😁
@vortexdeo4545
@vortexdeo4545 2 жыл бұрын
29:25 Burnout. Tough times.
@Aryan-se7zh
@Aryan-se7zh Жыл бұрын
WHY CAN'T WE DO THIS BY THIS APPROACH? #include #include int minimumElements(vector &num, int x) { int n = num.size(); if(x == 0) return 0; int ans=0; sort(num.begin(), num.end()); for(int i=n-1;i>=0;i--){ ans += x/num[i]; x = x%num[i]; } if(x == 0) return ans; else return -1; }
@manikantadevadiga7146
@manikantadevadiga7146 Жыл бұрын
sort.
@johnangelo2000
@johnangelo2000 9 ай бұрын
@7:22 "Kaise niklega answer !! Arey Bhaiya bahut simple lag raha hai thoda sa !! Theek hai !!!" ..
@Abc-lr4bf
@Abc-lr4bf Жыл бұрын
understood very well
@nayanjaiswal
@nayanjaiswal 2 жыл бұрын
Present sir 🙏
@mohitdeo780
@mohitdeo780 Жыл бұрын
if (target
@yashwantmishra9109
@yashwantmishra9109 2 жыл бұрын
Watching you design course 🙂
@energy4562
@energy4562 3 ай бұрын
love you bro 😍
@sukhjitsingh959
@sukhjitsingh959 2 жыл бұрын
Sukhjit present here nice 👍
@amaljogy4319
@amaljogy4319 2 жыл бұрын
Incase anyone wants the right Memotizatoin code by recursion -> int solveMem(vector& coins, int n, vector& dp){ // base case if(n==0) return 0; if(n
@VikramSingh-cc6np
@VikramSingh-cc6np 2 жыл бұрын
mja aa gya bhaiya best quality content free of cost dekh ke
@jyotiradityayadav6247
@jyotiradityayadav6247 2 жыл бұрын
Bhaiya memoization TLE nhi dega Aapne Memoization me recurssion wale function ko call kr diya hai isliye woh TLE dera uski jagah memoization wale function ko call kroge toh shi ans dega solveMem(num, x-num[i],dp);
@sounaksaha1455
@sounaksaha1455 2 жыл бұрын
+1
@priyankajhamb7061
@priyankajhamb7061 2 жыл бұрын
Thankyou Sir
@JohnSmith-uu5gp
@JohnSmith-uu5gp Жыл бұрын
Awesome 🥰
@SajanKumar-ec2us
@SajanKumar-ec2us Жыл бұрын
Include why memoisation and dry run of tabulation
@saqibmasood501
@saqibmasood501 2 жыл бұрын
sort krke aur optimize krskte the kya
@shubhamistic
@shubhamistic Жыл бұрын
on 11:19 you are not returning ans from main function i.e "minimumElements" so how you are able to get your all test cases passed ??
@paarthpatel861
@paarthpatel861 2 жыл бұрын
Keep doing it
@m.afnan2018
@m.afnan2018 2 жыл бұрын
LoveForBhaiya++;
@shubham57641
@shubham57641 2 жыл бұрын
Memoization code was absolutly fine there was only one mistake making recursive calls int Helpher_minimumElents(vector &num, int x,vector &DP) { //bse case if(x==0)return(0); if(x
@sakilahmed2911
@sakilahmed2911 Жыл бұрын
I noticed that
@sagnikmodak4178
@sagnikmodak4178 Жыл бұрын
thanks sir
@rishitshah2602
@rishitshah2602 2 жыл бұрын
8:20 WhatsApp notification came
@sahilanand30
@sahilanand30 2 жыл бұрын
🔥
@AshutoshEE-
@AshutoshEE- Жыл бұрын
Swad++ bhaiya🙏🙏
@randomguy7246
@randomguy7246 Жыл бұрын
bhaiya DRY RUN isme aapne nai kraya jaise pehle me krwaya tha wo x-num[i] relation etc usse smjhne me assani hoti
@BereniceVirginis
@BereniceVirginis 10 ай бұрын
what about using greedy algorithm, I think it will improve our solution
@kanhaiyalalkumawat7055
@kanhaiyalalkumawat7055 2 жыл бұрын
superb
@AbhishekGupta-cg2vj
@AbhishekGupta-cg2vj 2 жыл бұрын
not understood bhiayaa
@silverlining7778
@silverlining7778 Жыл бұрын
helpful video
@Its_._aayush
@Its_._aayush Жыл бұрын
maja aagya
@vishalgarna4580
@vishalgarna4580 Жыл бұрын
Samajh+++
@vishalgarna4580
@vishalgarna4580 Жыл бұрын
Achi hai
@insaafarmy786
@insaafarmy786 Жыл бұрын
sab dimak k upper sey
@eprithvikushwah4754
@eprithvikushwah4754 Жыл бұрын
Maza aaya
@DurgaShiva7574
@DurgaShiva7574 Жыл бұрын
out of ALL the videos which you have made til date....this is the first , and the only video.. jaha pe mereko samajh nahi aaya :(
@chainsawman-hell666
@chainsawman-hell666 Жыл бұрын
bilkul
Lecture 105: Maximum Sum of Non-Adjacent Elements || DP Series
20:33
CodeHelp - by Babbar
Рет қаралды 106 М.
Coin Change - Dynamic Programming Bottom Up - Leetcode 322
19:23
كم بصير عمركم عام ٢٠٢٥😍 #shorts #hasanandnour
00:27
hasan and nour shorts
Рет қаралды 11 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 22 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН
16  Coin change problem: Minimum number of coins
25:54
Aditya Verma
Рет қаралды 280 М.
Lecture 107: Cut Rod into Segments of X, Y, Z || DP Series
24:39
CodeHelp - by Babbar
Рет қаралды 78 М.
The Best Way to Learn Linux
9:45
Mental Outlaw
Рет қаралды 130 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
كم بصير عمركم عام ٢٠٢٥😍 #shorts #hasanandnour
00:27
hasan and nour shorts
Рет қаралды 11 МЛН