@@TheAdityaVerma maine kosis ki bahot bar ghumane ki but failed :(
@amansharma78654 жыл бұрын
bhai uske liye jee ki coaching leni pdti hai...udhr seekh jate hain pen ghumana apne aap 🤣
@nikhilnaidu13834 жыл бұрын
@@amansharma7865 hahahha
@amanwatts244 жыл бұрын
@@TheAdityaVerma For every new DP problem first we should write recursive code and then convert it to bottom up approach ?
@noobichesser94343 жыл бұрын
Engrave this in stones and history will witness that best ever tutorials created for Dynamic Programming on entire planet was created by Aditya Verma. Period.
@ytg66632 жыл бұрын
Ok
@AniketSingh-nx4ds Жыл бұрын
striver better now
@anonymousanonymous7507 Жыл бұрын
@@AniketSingh-nx4dsno
@shivendrasingh85206 ай бұрын
@@AniketSingh-nx4ds bhaiya abhi bhi aditya verma is best in terms of dp bhai
@30sunique785 ай бұрын
Everyone have different perspectives. If it's not best then What's doing here Dude 😂 @@shivendrasingh8520
@shadowofthecorpse94814 жыл бұрын
Thanks for this DP series Aditya! Great tutorial but I spotted one small potential mistake in the initialization part at 10:40. The problem is, that initializing the entire column with 1 will work only if the input array has all non-zero elements. As me and a few others have pointed out, the method fails when the input array has any zeros. For eg: n=3, sum=0. We can have a set here as {0,1,2}, so there'll be subsets of {} and {0} possible hence count will be 2. This is true for multiple other input arrays where actually count >1 for sum=0, but we initialized count=1 for all input arrays when sum=0. Here's a small fix I found to the issue: We initialize the first column of the array acc to the formula: 2 ^ (no of zeros in the array at that size). Hence, for eg: arr={0,0,1,0}, sum=0 For n=0, value will be 2^0 = 1, i.e {} For n=1, value will be 2^1 = 2, i.e. {} and {0} For n=2, value will be 2^2= 4, i.e. {}, {0}, {0} and {0,0} For n=3, value will be 2^2 = 4, i.e. {}, {0], {0}, and {0,0} For n=4, value will be 2^3 = 8 i.e. {}, .............., {0,0,0} Reason: In the sum of subset problem, we simply needed to return whether or not a set exists for sum=0, which was always True as empty set {} was always existing. Here, we need to return count of subsets for sum=0 (for first column), which will include all possible subsets in the array which add up to 0.
@jyotijangid52434 жыл бұрын
can you share the link of the code here? I am getting the wrong number of counts.
@shadowofthecorpse94814 жыл бұрын
@@jyotijangid5243 Sure, it's in Python: def find_zeros_in_array(arr): return len([x for x in arr if x==0]) def count_of_subsets_with_given_sum_corrected(arr,n,W): K = [[0 for x in range(W+1)] for x in range(n+1)] for i in range(n+1): for j in range(W+1): if i==0 or j==0: if i==0: K[i][j] = 0 if j==0: K[i][j] = 2**find_zeros_in_array(arr[:I]) #the only line that's different from the video elif arr[i-1]
@ravishekranjan72824 жыл бұрын
Thanks man for this observation
@jyotijangid52434 жыл бұрын
@@shadowofthecorpse9481 Thankyou
@ironmonk40744 жыл бұрын
I think he mentioned it at 12:42 that this solution is only for the case when all the numbers are positive in the given array. Still great solution for the case of including a zero.
@ankitsablok9522 жыл бұрын
This lecture series is going into a hall of fame for all things algorithms. Watching your videos is synonymous with watching a movie. What a flow and what a way of presenting the information. Dude man you deserve to be a teacher of CS concepts, open an NGO bro or keep uploading such stuff. One word to sum it all #AMAZING!!!!!
@0anant04 жыл бұрын
9 of 50 (18%) done! I think need more explanation as to why we consider if (cur_elem
@priyalagarwal99964 жыл бұрын
Definitely true when you said - "Yaar aisi problems krne mai kitna maza aara hai!!". Finally now my DP-phobia is going away and i am actually enjoying your videos!! Thank you bro :)
@samirpanday48984 жыл бұрын
dp-phobia is real . repeat after me.
@kaushalmzp3 жыл бұрын
same here
@vibhu6133 жыл бұрын
@@samirpanday4898 sahi hai.....
@rishabhjoshi30922 жыл бұрын
hi, i am new here, he explains the concept, but what about coding? we have to do that ourselves? which language he uses in videos , c++ or java?
@arfaatsyed68532 жыл бұрын
@@rishabhjoshi3092 hello, he just explains to generic code to solve the given problem. You can apply them any language. If you're using java you can replace some of the code with java methods. But the code he explains in any language Is more or less the same
@ShubhamKumar-rv5qh3 жыл бұрын
I was literally waiting for something diff. but the next moment you said " HO GAYA BHAI"
@saptarshibose97183 жыл бұрын
I have tried many DSA related videos but frankly speaking, you are the king of DSA for teaching the subject easily. Because of you now DP or DSA looking like a piece of cake.!
@rajatgupta74884 жыл бұрын
17:18 !!!! Ultimate Swag !!!
@akhiljain16954 жыл бұрын
I'll definitely share this channel of yours, because the explanation is just beyond amazing. Request you brother to keep making such videos.
@rishabhjoshi30922 жыл бұрын
hi, i am new here, he explains the concept, but what about coding? we have to do that ourselves? which language he uses in videos , c++ or java?😊
@akhiljain16952 жыл бұрын
@@rishabhjoshi3092 My suggestion would be to pick Java or Cpp and try coding few problems initially and using standard libraries that provides data structures and algorithms. Once you code out a few problems. You'll get a hang of it and all you will then need is the logic which this guy is serving in an unmatchable way.
@mohit84604 Жыл бұрын
@@rishabhjoshi3092 c++
@bavarvaneel53 жыл бұрын
Me: "I'm not able to understand DP" Professor: "You are dumb!!!" Lee Aditya Verma: "Hold my beer🍺"
@tejasasthana69513 жыл бұрын
*aditya verma: hold my pen
@AvikNayak_3 жыл бұрын
@@tejasasthana6951 no hold my camera hoga agar pen de dega toh likhega kisse
@aptitudepointiit-bhu53582 жыл бұрын
Awesome explanation. Bhaiya you have only considered the case for positive elements. If zero/es is/are also present in the array (as it is in gfg question), then we need to iterate: for(int i=1;i 0) => dp[i][0] = dp[i-1][0] else If(arr[i-1] dp[i][0] = dp[i-1][0] + dp[i-1][0]; and this extra term will lead to extra +1. And this extra +1 will exist whenever arr[i-1] == 0. Thus increasing our answers by no. of zeroes whenever required.
@sarthakbhatia76392 жыл бұрын
Right in that case I think we can initialise it to number of zeroes as it will be equal to the number of subsets.
@yashrajpathak81032 жыл бұрын
sir big fan
@varshikjain18622 жыл бұрын
what is the value of 'm' here in if(arr[i-1]>j) dp[i][j] = (dp[i-1][j])%m;
@fardeenalam69292 жыл бұрын
@@varshikjain1862 10^9 + 7
@harshitewari6 ай бұрын
needs to be a pinned comment!
@purut51054 жыл бұрын
"Han bhai bs khatam hogya !!!" Apka ye line maja hi ajata h . Thank you so much Aditya , now I'm Loving DP!!!!!!
@himanshukaushik9484 жыл бұрын
Hamesha shochta tha ki koi senior mentor mil jae. Aaj mil gaya bhai. Bhot shi videos h
@avadhoot052 жыл бұрын
📢📢Aditya's solution will fail for testcase that includes 0s in input array. While initialization, in case of sum == 0, he is directly considering that only empty subset exists hence he is storing 1 in first column. But consider, input arr= [0,0] and sum = 0. here we CAN'T initialize first column with 1 since for sum = 0, subsets are {0(0th index)}, {0(1st index)}, {0,0} , {}. i.e. count 4. The only change will be to use if(sum == 0 && n == 0) then assign 1. (THIS CONDITION IS IMPORTANT) if(n == 0) then assign 0 and rest will be handled by pick/no pick algo. Thanks!! and overall great explanation by Aditya Verma💯💯
@aarchigandhi6617 Жыл бұрын
Thankyou so much!! It helped me:)
@manavjain445321 күн бұрын
Thankyou so much. this one important condition used up a lot of my time.
@ramrana52574 жыл бұрын
2 GODS who use DP snax Aditya verma
@smitchaudhari97834 жыл бұрын
Underrated comment 😉
@miteshbhuptani55424 жыл бұрын
tushar roy
@manikantareddy75954 жыл бұрын
Bhai Aap OP biroooo.
@prateekarora45494 жыл бұрын
snax kon hai??
@nikhilnaidu13834 жыл бұрын
@@prateekarora4549 pubg player hahaha
@rupesh_dharme2 жыл бұрын
I think in initialization we should only initialize the first row with 1 at (0, 0) and start second for loop with j = 0, because initializing the first column with all 1's might give the wrong result if there exists a 'zero' in the array. Input for which this initialization do not work: n = 10 sum = 31 9 7 0 3 9 8 6 5 7 6 Correct me if I am wrong.
@sigmarules75042 жыл бұрын
correct
@architarora-iiitd32652 жыл бұрын
*Important point which is missed in the video* int perfectSum(int arr[], int n, int sum) { // Using DP int dp[n+1][sum+1]; int N = n+1; int M=sum+1; int mod=1e9 + 7; //Initialization for(int j =0; j
@hemang102 жыл бұрын
@@architarora-iiitd3265 Your argument is correct. but we don't need to initialize the array the way you said. Just initialise the first column with 1s. Then, just start the inner loop of j with j=0, as pointed out by some of the other comments. This will do the needful. The values of the first column will automatically get updated as the iterations proceed. so there is no need to manually check the number of zeros.
@architarora-iiitd32652 жыл бұрын
@@hemang10 Yes, correct. I just wanted to highlight the point that what does initialising the first column to 1 denotes.
@stellararts99262 жыл бұрын
@@hemang10 Thankyou! Great explanation
@devanshishah10043 жыл бұрын
I was looking for good DP series since last 1 year. Finally found this one. Best series ever. Can never thank you enough!
@akshatsahu80213 жыл бұрын
I watched your video, tried the question on gfg, it got submitted.. I was happy.. Then I realized that I did a mistake, I came back to your video and corrected by mistake of forgetting to give it a LIKE. You are awesome bhai..
@rajenderpassi9831 Жыл бұрын
For those who are wondering about why the problem is not being submitted on GFG. Here is the solution:- int perfectSum(int arr[], int n, int sum) { int t[n+1][sum+1]; memset(t,0,sizeof(t)); int cnt=1; t[0][0]=1; for(int i=0;i
@abhayjoshi362 Жыл бұрын
didnt quite get why its happening can you elaborate or explain with eg ?
public static int findWays(int nums[], int sum) { int N = nums.length; int[][] mat = new int[N+1][sum+1]; mat[0][0] = 1; int mod= (int)1e9+7; for(int i = 1; i < N+1; i++) { for(int j = 0; j < sum+1; j++) { if(nums[i-1] > j) { mat[i][j] = mat[i-1][j]; } else { mat[i][j] = (mat[i-1][j-nums[i-1]] + mat[i-1][j])%mod; } } } return mat[N][sum]%mod; }
@LivenLove2 жыл бұрын
Really appreciate the level of mastery you have.. thumb rule yehi hai ki agar koi kisi aur ko concept samjha sakta hai toh his concepts are super strong, warna possible hi nahi hai.. baki log direct code likh dete hai pura ka pura phir walk through karenge.
@akshatkumar29602 жыл бұрын
while solving this problem on gfg you will encounter test cases where they have also included 0 in the array, so in order to tackle that scenario, only fill the first row for base case. Next start filling following rows using the technique of include/not include. As for ex: if there is only 0 in array then as per base case the ans will be 1, however actually ans has to be 2: 1 empty subset and 1 subset with 0
@harmansinghsaini9515 Жыл бұрын
can you provide solution as it still not working
@sohanshrungare8930 Жыл бұрын
thankyou for this comment and the explanation
@beingnitian2745 Жыл бұрын
@@harmansinghsaini9515 j ko zero se likho code likhthe time thats it
@avinesh8350 Жыл бұрын
If 0 in the array then just reverse the array in descending order.
@surajkumar9756 Жыл бұрын
@@beingnitian2745 kaam ni kr raha hai
@AkGautam_19043 жыл бұрын
Sach bta rha hu aisa content kahi nhi milega❤️. Really your way of teaching is awesome.🤩🤩🙌🙌🙌 Thanks a lot sir🙏🙏
@prachipardhi63244 жыл бұрын
Thankyou so much for making these videos ......they have made me fall in love with DP ...........I love your way of teaching ..
@AyurvedaAddict2 жыл бұрын
20:31 apka aadesh sar aakhon par sir ji ..... Greatest Explanation.........
@ameerulshah40984 жыл бұрын
We can use this same code for subsetSum problem as well And if value of final grid(t [ n ] [ sum ]) is > 0 return true.
@VishalSharma-hq5ti4 жыл бұрын
Yes, but that would be bad as it will take more memory(bool - 1 Byte, int - 4 Bytes).
@devendrasingh47764 жыл бұрын
True but overkilling..
@abhisekhagarwala31152 жыл бұрын
I just want to appreciate your hard work. Initially I was skeptic about your video . Then i was facing issue with solving problems. Then one Friend recommended me your videos. Rest i first watched your recursion playlist. And now I am watching this series. You are great man.
@koustubhmokashi40473 жыл бұрын
I can see the difference between just a tutor and developer + tutor, and you fall into 2nd category, it's really difficult to explain these concepts , but you did it very well
@lakanavarapunagamanikantaa72993 жыл бұрын
for reference see this i do this after watching this video def path(arr,s,t,count=0): if s
@rishabhmishra27603 жыл бұрын
Amazing explanation brother I never see this type of explanation in my coding history!
@Udayyadav-zg6nl4 жыл бұрын
Make videos on graph , backtracking and window sliding please. I like your approach towards concepts..You will rock Big bro .
@rahulagarwal48744 жыл бұрын
Brother, i can't tell you how much important this lectures of DP are for me. Thank You so Much..
@shivambhanu27573 жыл бұрын
Concept ki feel aa rahi hai bhai. Thanks a lot.
@intelligentprogrammer3 жыл бұрын
I have one doubt in this video, Before this video or before using '+' , I was able to think of the changes like instead of T/F, we use 0/1 but regarding '+', I am not able to understand completely how we have used '+' by replacing '||'. If anyone knows ,then let me know too.
@vishalvishwakarma82763 жыл бұрын
I know what you are going through but I'll tell you to draw the matrix and fill it code wise, although aditya content is great, try pep coding's "Target sum subset" then perform the code on a paper, you will get a clear idea what's happening inside.
@hasansayeed21553 жыл бұрын
vishal vishwakarma in the subset problem aditya used t = t[i][j-wt[i-1]] || t[i-1][j] But here he used t = t[i-1][j-wt[i-1]] + t[i-1][j] t[i] / t[i-1] which one is corrrct we include the element in our set?
@akash-lz2dq3 жыл бұрын
dekh bhai tu startting se 4th element pr hai or ab tu chahta hai no of ways ki subset sum given sum ke braber ho jaaye toh, vo tarike jnme is 4th element ko include krke given sum mil rha hai + vo tarike jinme is 4th element ko include na krke bhi sum mil jaa rha hai, vo total hoga
@shivamtiwari36723 жыл бұрын
if u have solved this problem using recursion before so it will be easy to understand bcz in recursion we call function 2 times 1st time we dont add element and in 2nd function we add element so when the added sum becomes equal to desired sum we do count++,so basically we are adding the count of both function called.
@vishalvishwakarma82762 жыл бұрын
@@hasansayeed2155 t[i-1] is the correct one, aditya did it wrong accidently. the explaination is that i = 1, represents wt[0], which makes it wt[i -1] to access each element of the given 1d array;
@geeteshpopli52854 жыл бұрын
I fell in love with DP because of you Thanks :)
@yashmishra57963 жыл бұрын
Should we bow!! Yeah Aditya Bhaiya Is a King!!!!
@parulsinghal85734 жыл бұрын
@Aditya Verma , Would you also upload a video where we are printing all these subsets as well .
@gamerhu74623 жыл бұрын
using recursion would be better ig
@Kuriocity3 жыл бұрын
static void findUniqueSubsets(int[] arr, int n, List temp) { println("temp (to add)! " + temp); //println("#" + list + "#"); if (n == arr.length) { println(n + ":" + arr.length); list.add(new ArrayList(temp)); println("#" + list + "added #"); } println("#" + list + "#"); if (n < arr.length) { temp.add(arr[n]); println("temp after add " + temp); findUniqueSubsets(arr, n + 1, temp); temp.remove(temp.size() - 1); println("temp after remove " + temp); findUniqueSubsets(arr, n + 1, temp); } }
@amansrivastava13323 жыл бұрын
2 points i would like to add - 1-For those getting problem with multiple 0s, just start the column loop with j=0 instead of j=1 like this. for(i=1;i
@DeepakSoni-zq5rd3 жыл бұрын
why we use t[i][j]= t[i-1][j-arr[i-1]] + t[i-1][j]; instead of t[i][j]= t[i][j-arr[i-1]] + t[i-1][j];
@coldfinger34723 жыл бұрын
@@DeepakSoni-zq5rd bro i resembles N(number of items) , either we include the item or exclude, we have considered the item, so in every case i will decrease.
@karanrocks44472 жыл бұрын
But marked t[0][0]=1.. Then only above code will work
@atv89922 жыл бұрын
why we getting error when using j=1 ?
@vibhugupta33312 жыл бұрын
@@atv8992 why j starts from 0 becoz in a given array we might have an element 0 which might gets missed out in case when j starts from 1
@ganavin34233 жыл бұрын
U win so many hearts....the reason for this is ur knowledge and helping nature.. Thanks bro!
@ankitadalmia20784 жыл бұрын
The way you find correlations between dp problems is amazing.
@vamsimudaliar86434 жыл бұрын
Could you please upload combinatorics problems . Worth watching ur videos. Its a very unique channel. Keep Going Bro !! . U earned a subscriber !!
@TheAdityaVerma4 жыл бұрын
Will try
@sreeraghuvardhanvangipuram95472 жыл бұрын
For the 0 edge case in GFG, I found an alternate way to deal with it. Ex: 2, 3, 0, 1 Our function calculates all possible calculations for elements before it. This means possibilities are calculated only for 2,3 as they come before 0. Possibilites with 1 are left out and ans is lesser. Hence if we shift all the 0's to the end we ensure to calculate all the possibilities. That is what i did. Add this at the beginning int[] temp_arr = new int[n]; int ind = 0; // The problem came when 0's are dealt before other elements which // meant that we calculated 0s permutations for a smaller subset // meaning the answer would decrease // By pushing 0's to the end, we ensure that the all permutations // of 0's are calculated thus giving us the right answer for(int i = 0; i < n; i++){ if(arr[i] != 0){ temp_arr[ind++] = arr[i]; } } for(int i = 0; i < n; i++){ arr[i] = temp_arr[i]; } Also do modulo 1000000007 when you are calculating t[i][j].
@MdKais-lf6wj4 жыл бұрын
vai,plz make a playlist on "GRAPH THEORY".please vai
@rahulchudasama93634 жыл бұрын
bhai genius tu, What a simple way u are solving problem..
@MOHITPATIDARRA2 жыл бұрын
A wonderful course given freely by GOD of DP. Thanks very Much Sir for providing Amazing Content.
@nihitjain36777 ай бұрын
agar array mai 0 bhi diya ho toh , sirf first row par hee lagana aisa 1 0 0 0 0 0 0 baaki ka leya loop hee chalana j=0 se chalega na ki 1 one se REASON ( agar array mai 0 bhi hai toh no of ways with sum=0 badh jayega {}, {0}, {0,0,0} isme jaise 3 ho gya
@sauravkumarsonu8293 жыл бұрын
True definition of Teacher, Aditya Sir, salute for your contribution. Apki wajah se aaj ham jaise log v aaj dynamic programming ko shi tarike se sikh rahe🙏❤️
@ShivamKumar-hf5ec2 жыл бұрын
// there is some modification required in the aditya's code that is the number of subsets of sum == 0 // the subsets will be the 2^i where i is the number of zeroes present in array till a given index . // you can also map the number of zeroes with the index this will reduce the complexity int count_zeros_till_index(int arr[],int i)//returns the numberof zeros in array till index i { int count=0; for(int j=0;j
@hemankpandya9892 жыл бұрын
exactly..........because element can also be zero........😁
@hemang102 жыл бұрын
I think we don't need to initialize the array the way you said. Just initialise the first column with 1s. Then, just start the inner loop of j with j=0, as you have done in your code. This will do the needful. The values of the first column will automatically get updated as the iterations proceed. so there is no need to manually check the number of zeros.
@WizBoyYt2 жыл бұрын
@@hemang10 Yeah, Counting will increase TC. Instead this multiply by 2 to last index's element
@user-jp9jd6el1f Жыл бұрын
constraint in a problem sum can't we 0 if u study problem carefully
@xsuritox10584 жыл бұрын
17:19 OOOO bhai, aise swap hote hai pen fingers k beech, Aditya Bhai OP🔥🔥🔥
@tridevthakur77112 жыл бұрын
Ur teaching style is awesome & plz make video on "LIS" and "kadane" using Dp
@pavankaranam7469 Жыл бұрын
best dp series.Period.
@tkishore12603 жыл бұрын
Bhai u r really amazing 👌👌.itna acha kaun padhata hai... 🙏🙏
@JacobAbraham-twozerosix4 жыл бұрын
Sir... Thanks for these video's. Your explanations are really good. I have one question. if we have a arr with zero's in it, for example arr = [0,0,0,0,0,0,0,0,1] and S = 1. The top-down approach gives me just 1, but the correct ans should be 256. How do we initialize the t when there are zero's in the array?
@pratikkedar99794 жыл бұрын
try arr = [1,0,0,0,0,0,0,0,0] and S = 1 you get 256
@shadowofthecorpse94814 жыл бұрын
@@pratikkedar9979 no you're changing the question. Even I have the same doubt as jacob
@harshittrehan62324 жыл бұрын
@Jacob Abraham the reason you're getting the wrong answer is because when we initialize the 1st column, t[i][0], we put 1 in there because in 1st column sum = 0 and an empty array sums up to 0, right ? But with zeroes, we can't put 1 in there. Because, consider this example: {0,0,0}, sum = 0 (1st column). Now, when i=0 (that is empty array.) then we put t[0][0] = 1. Makes sense. Now, i=1, i.e., elements = {0} and sum =0. The answer here is not 1 now. It is 2 because: {} -> empty subset sums up to 0. Good. {0} -> this subset also sums up to 0. Now, see i = 2 i.e. elements = {0,0} {} -> sums up to 0 {0} -> sums up to 0 {0} -> sums up to 0 {0,0} -> sums up to 0. Total 4! So we have 2 zeroes in the array till index 'i', so value is 2^2 = 4 Finally, i=3, elements = {0,0,0} => 3 zeroes => 2^3 = 8 subsets possible. Basically, for every index 'i' in column 0, you need to check the number of zeroes in arr[0...i-1] and then put the value 2^(number of zeroes in array till index 'i') in the cell.
@ritish_sehgal3 жыл бұрын
This question assumes that array consists of only natural numbers, otherwise our Initialisation for first column would be wrong!!!!
@gauravmaurya25993 жыл бұрын
@@harshittrehan6232 awesome explanation bro..
@taniyagupta8404 жыл бұрын
Please bhai, Graphs pr bhi video bnao. Keep up the good work. Thank You :)
@ayushbhardwaj67833 жыл бұрын
Thanks a lot Aditya. I was looking for videos to help me understand how to think DP way..!!! You immensely helped me. :)
@gauravpareek37839 ай бұрын
Bhai what a content you have created...hats off to you! For this particular question we could do it by having the same matrix as for subset sum right? and then count the number of Trues present in t[i][10] and that should give us count of subsets? Is my understanding correct here?
@adarshsrivastav39913 жыл бұрын
These videos are so good man! Thank you for providing it for free!
@SurajKumar-ex2kx3 жыл бұрын
Thank you so much sir. loving this series so much now Dp is my new crush due to you.
@LuciferScripts2 жыл бұрын
lord of Dp. Thanks Bhaiya💙
@harshchaudhary81823 жыл бұрын
very underrated youtube channel, this is best u can get .
@ashutoshdhyani89464 жыл бұрын
Aditya...I had a query...cant we do this by same code as the equal partition sum....and at end traversing the T[0....n][sum] column and RETURNING NUMBER OF TRUE FOUND IN THAT COLUMN.....?..(btw loved ur videos
@varunmahendra77722 жыл бұрын
Thank you.. Thank you so much for standing by someone like me who is almost into depression just to understand these topics. That thank you id from bottom of my heart 🥺
@umangjain38754 жыл бұрын
Your explanation - awesome :) Thanks a lot bro. Never thought DP can be that easy :D
@ameynaik27433 жыл бұрын
Great video! Is there a leetcode problem based on this concept?
@lifewithniharikaa3 жыл бұрын
Finally I reached a state at which I am able to do the question by my self.Thank youuu
@DheerajGupta06513 жыл бұрын
Congratulation brother on 100k subscribers you deserve millions of subscribers and one day you will achieve it.🎉🎉👏
@TheAdityaVerma3 жыл бұрын
Thanks ❤️
@lakshya85326 ай бұрын
Just a tip starts top-down dp loop, for J = 0 to sum+1, to handle If there is some 0 in the given array
@thisthatvlogs53342 жыл бұрын
And the best channel to learn dynamic programming
@a.yashwanth4 жыл бұрын
I think there is no need. You can initialize dp[0][0]=1 and dp[0][1..sum]=0 Now you have only 1 row initialized. Now if you run the dp from i=1..n and j=*0*..sum If we run the j loop from 0..sum instead of 1..sum, it will count number of subsets for 0 too. If you still don't understand *how*: In first loop we are at _ element.(sum=0) 1 0 0 0 0 0 0 0 0 0 _ Now we apply the condition. if(0
@sarthakbhatia78884 жыл бұрын
doubt: in case when zeroes are present in the set given, the entries in the zeroth column may change for eg : arr[]={0,0,11,1}; then extra subsets for sum=0 {0},{0,0},{} so 1 will not work.
@najimali324 жыл бұрын
for each zero there will be two possibilities so count extra_zero & then add 2*extra_zero +t[n][W]
@a.yashwanth4 жыл бұрын
@@najimali32 I think there is no need. You can initialize dp[0][0]=1 and dp[0][1..sum]=0 Now you have only 1 row initialized. Now if you run the dp from i=1..n and j= *0* ..sum So we run the j loop from 0..sum instead of 1..sum, it will count number of subsets for 0 too. If you still don't understand *how* : In first loop we are at _ element.(sum=0) 1 0 0 0 0 0 0 0 0 0 _ Now we apply the condition. if(0
@ankitsrivastava29294 жыл бұрын
8:07 reduce playback speed to 0.75 and learn that too!!!!!
@Akshitgupta14 жыл бұрын
"Yaar aisi problems krne mai kitna maza aara hai!!", just awesome!
@indianyatrivlogs4 жыл бұрын
Sir!please make videos on backtracking as well ❤
@ketanraut94683 жыл бұрын
Definitely the best dp explaination ever🔥👍
@peoplechoice78483 жыл бұрын
Bhai aapka knowledge toh kamaal ka hai bhai
@namangupta86092 жыл бұрын
bhai aap unsung hero ho placements ki duniya k
@abhishekpaul8515 Жыл бұрын
100x better than any paid course 🔥
@hemantmarve36744 жыл бұрын
DP looks very easy after Learning from u.Thanks bro.
@arpanbanejee51433 жыл бұрын
Baki log sab matrix bharne lag jaate hain! Code karne aye ho matrix thodi na bharne aye ho! True AF!!
@priyarathore92663 жыл бұрын
Best DP course on internet!
@onkarjoshi8811 Жыл бұрын
need more explanation on why used + did not understand the intuition behind it
@codelover8474 жыл бұрын
Vai u're love. BitManipulation ka vi video banao.. Especially the approach needs to be understood and u're just nailing it.
@TheAdityaVerma4 жыл бұрын
Thanks brother, next is binary search. I will consider making on Bit Manipulation. Thanks for the advice.
@nemesisanims74014 жыл бұрын
@@TheAdityaVerma Bhaii please yaar bass itna bata sakte ho aap ki minimum path sum kis type ka dynamic problem Qn hai ??? Please iska reply zaroor karna yaaran
@lifeexplorer29654 жыл бұрын
You Nailed it ,awesome
@BHARATKUMAR-dk1ij3 жыл бұрын
you r a legend, yaar matlab extra dimmag lag hi nahi raha ,just normal changes and everything is explained properly
@AnkitAsatiM104 жыл бұрын
every time I watch your video, ek jaadu ki jhappi dene ka mann karta hai...😉😃😃❤️
@vakhariyajay2224 Жыл бұрын
Thank you very much. You are a genius.
@ayushbansal92124 жыл бұрын
Coding wale bnde hai ab baithke table thoda na bharenge!, Great video!
@TheAdityaVerma4 жыл бұрын
Exactly brother !! ✌️
@AnkitKumar-yj1sy4 жыл бұрын
Nice video 👌👍 awesome!!
@ankitchouhan88283 жыл бұрын
Great Video Brother. Keep Growing.
@raviapiit4 жыл бұрын
"kya samjhate hain samjh nahi aata" :D Exactly, most of the time they fail to explain "why" ? instead directly start telling it's DP problem. But, first of all we need to understand why DP why not recursion or any other method. How would someone conclude that's DP problem (when looking at the similar problem in interview/exam). Most of the youtuber skip this part.
@a.yashwanth4 жыл бұрын
especially tushar. tushar: see's a dp question also tushar: turns on camera and starts explaining the dp table immediately.
@gautamvashishtha39234 жыл бұрын
Bhaiya it would be awesome if you could do a similar series on Divide and Conquer based questions :) Thanks for the help
@sumitbhuwalka3 жыл бұрын
@Aditya Verma Firstly the video and approach is very good. I tried this approach but it was failing for test cases containing multiple 0s such as: arr[]={0,0,1} sum=1 Expected Output: 4 My Output: 1 Maybe I missed something, can you suggest me something? P.S.: The testcase is present in leetcode targetsum problem as {0,0,0,0,0,0,0,0,1}, sum=1, correct ouput = 256, my output=1
@BiharCentralSchool3 жыл бұрын
Start second loop from 0. int perfectSum(int arr[], int n, int sum) { int dp[n+1][sum+1]; for(int i=0;i
@codetochange82 жыл бұрын
@@BiharCentralSchool It helped a lot ...Thanks!
@damnitboi41463 жыл бұрын
Bro i donno hindi much still I am able to grasp stuff and this is legendary 🔥🔥🔥🔥🔥🔥
@stayawakebrother10 ай бұрын
impressed by the 8:08 pen trick
@gauravbhisikar63814 жыл бұрын
thank you bhai you explained 1000x better than my college teachers
@niladribiswas12112 жыл бұрын
After we generate the dp or t matrix , if we count number of true at last column we can get the number of subset. Can we say that?
@vatsalagarwal86804 жыл бұрын
If there is a number 0 in the array given initializatoin will be different for j = 0, as it will come 2 somewhere ?
@paramgoswami72244 жыл бұрын
See if there is 0 in the array, do the code for non zero elements.. And then multiply the answer by 2 as you will get one subset without taking 0 and other taking 0 both will give same results
@a.yashwanth4 жыл бұрын
@@Astagfirullah.. There is code in this comment section.
@a.yashwanth4 жыл бұрын
@NAJIM CHOUDHARY I think there is no need. You can initialize dp[0][0]=1 and dp[0][1..sum]=0 Now you have only 1 row initialized. Now if you run the dp from i=1..n and j= *0* ..sum So we run the j loop from 0..sum instead of 1..sum, it will count number of subsets for 0 too. If you still don't understand *how* : In first loop we are at _ element.(sum=0) 1 0 0 0 0 0 0 0 0 0 _ Now we apply the condition. if(0
@harshittrehan62324 жыл бұрын
@@a.yashwanth this is the more efficient approach. Thanks. I went with 2^num of 0's, but this is better.
@A_CupOf_Life7 ай бұрын
Amazing explanation brother. But Bhai same code nai chala, (in gfg), after searching here n there(took lot of time) found the reason.,(After Initialization , for loop (for sum) should start with 0, and not with 1). You could have mentioned this point as well in video.😊
@mukulbakshi284 жыл бұрын
Love you Bro, Ab lag rha hai ki koi Jada Smart ni hota all are equal its just concepts that you make very easy bro. One Feedback bro please also mention Space-Time Complexity analysis during Problems.