WORKING CODE FOR: leetcode.com/problems/binary-tree-maximum-path-sum/ int solve(TreeNode* root,int& res) { if(root==nullptr) { return 0; } int l=solve(root->left,res); int r=solve(root->right,res); int temp=max(max(l,r)+root->val,root->val); int ans=max(temp,l+r+root->val); res=max(res,ans); return temp; } class Solution { public: int maxPathSum(TreeNode* root) { int res=INT_MIN; solve(root,res); return res; } };
@TheAdityaVerma4 жыл бұрын
Just a minor change from what I taught, think about it and you will get for sure. kzbin.info/www/bejne/d6OxqqimmpKLfpI
@cs208anjaysahoo24 жыл бұрын
Bhaiya above solution is for the previous problem (Video number 49) and it works perfectly fine, but for this question, your solution in the video doesn't work. Just now completed your DP series and it is the best series on DP .Thanks a lot for making these video from now on my fear for DP has reduced. Looking forward to watching your other video too:)
@sohelsheikh19343 жыл бұрын
Video solution will not work for Negative values , Correct Solution : - eg case = -10 -1 0 3 class Tree { int res ; int maxPathSum(Node root) { res = Integer.MIN_VALUE; solve(root); return res; } int solve(Node root){ if(root ==null){ return 0; } if (root.left == null && root.right == null) return root.data; else{ int l = solve(root.left); int r = solve(root.right); if( root.left == null){ return r + root.data; } if( root.right == null){ return l + root.data; } int temp = Math.max(l,r) + root.data; res = Math.max(res, l+r+root.data ); return temp; } } } Your Welcome :)
@hemanthlishetti75363 жыл бұрын
this code is also not working for test case -9 6 -10
@raajanashishpal49843 жыл бұрын
This will work for all the cases public class MaximumPathSumLeafToLeaf { private static int maxPathSum = Integer.MIN_VALUE; public static void main(String[] args) { // int[] treeArray = new int[] {20, 2, 1, 3, 30, 32, 28, 33, 26, 34, 35, 36, 24, 23}; int[] treeArray = new int[] {10, 5, -3, 12}; Node root = BinaryTree.initialiseTree(treeArray); maxPathSum(root); System.out.println(maxPathSum); } public static int maxPathSum(Node root) { // Base condition if (root == null) { return 0; } if (root.left == null && root.right == null) { return root.data; } // Hypothesis step int lpsum = maxPathSum(root.left); int rpsum = maxPathSum(root.right); if (root.left == null) { return rpsum + root.data; } if (root.right == null) { return lpsum + root.data; } // Induction step // When current node is root node for path giving maximum path sum int pathSumToPass; pathSumToPass = Math.max(lpsum, rpsum) + root.data; // data+lda+rda when current node is root node for path giving maximum path sum // Choose the case for maximum path sum int tempPathSum = Math.max(pathSumToPass, root.data + lpsum + rpsum); maxPathSum = Math.max(maxPathSum, tempPathSum); return pathSumToPass; }
@0anant04 жыл бұрын
49 of 50 (98%) done! Finally finished the series! It was a great experience! Thanks!
@TheAdityaVerma4 жыл бұрын
Congratulations Bro, I was waiting for this, saw your comment on each video 😅
@0anant04 жыл бұрын
@@TheAdityaVerma Thanks! I had code for almost all the problems but did not understand the underlying patterns -- it was evident from the copious amount of comments I had added to each code to try to understand. :-) Now, when I visit the code, it makes a lot of sense. e.g. today, I was looking at LC 664 'strange printer' and LC 241 'diff ways to form expr' code and realized it was the MCM pattern! It would be great if you could add the remaining DP patterns. BTW, I also completed recursion and binary search series. I am going to watch each and every video of yours!
@LegitGamer23453 жыл бұрын
if it helps , i think that video 27 was this problem - longest palindromic substring , so now you can go ahead and get 100% completion :)
@kushal74063 жыл бұрын
Yeah, same dude. Thanks to aditya bhaiya for such a great content🤗
@WhyYouN00B2 жыл бұрын
Bhai aapki placement kaha hui hai aditya sir videos dekh kar
@shahabakhtarrabbani68643 жыл бұрын
Legends say he's still having his lunch :D Thanks a lot for this playlist!!
@dhruvagarwal6463 жыл бұрын
At the last just want to say: "THOSE WHO CAN'T REMEMBER THE PAST ARE CONDEMNED TO REPEAT IT" ~Dynamic Programming
@opera38463 жыл бұрын
💯
@ogbuddha78352 жыл бұрын
Now i can understand why
@thiswasme54522 жыл бұрын
Great !!
@ManojKumar-rg8ez2 жыл бұрын
If you watch any of the video of this channel, you are bound to watch all the videos. It's safe to say these videos gives wings to everyone who wants to fly in the sky of the algorithm's space on it's own. I have never came across the videos which explain such a wonderful manner, now recursion does seems like a magic which we can perform!
@vishaljaiswal16043 жыл бұрын
Phewww...Finished all the 50 Questions and What a journey it has been, right from scratch to solving trees,I never did this in college but after 5 years of work ex, I landed up here and learned dynamic programming.Thank You, Aditya Verma, even a gazillion of thank you will not be enough, and Above all the way you explained each and everything was mind-boggling and magical. More power to you.Keep spreading knowledge.Forever Grateful
@vishal_rex3 жыл бұрын
Finally I've completed your entire DP playlist. Before that, I have completed recursion playlist also. Here are some changes in my problem solving ability: * I'm not afraid of DP anymore. * Solved C type ques of live contest in Codeforces using DP. * Solved daily leetcode challenge ques which was based on 3d matrix DP on knapsack. * Partially solved Codechef's long challenge's last ques (toughest) using recursion. I followed one approach while watching your every video. I made sure to code along with your explanation. I paused video after getting to know the problem statement, most of the time I could derive the solution myself from the previous analysis of yours. I went through entire comment section of each video in order to get more info about the solution. Thankyou so much for such a quality content ❤❤❤
@thinkingmad16853 жыл бұрын
Wow nice to hear that ,I m going to start this journey now wish me luck
@vishal_rex3 жыл бұрын
@@thinkingmad1685 all the best
@The_Promised_Neverland...3 жыл бұрын
Baasss bhai kitna fekega😂
@deepakgurjar37462 жыл бұрын
chal bhai is que ka soln to bta de...]
@vishal_rex2 жыл бұрын
Revisiting this comment thread after 1 year.. updates: I'm SDE at Amazon that too being from tier3
@robbie261019908 ай бұрын
1.4 mill started this journey , kudos to the 92k who finished it 😄
@lifehustlers164 Жыл бұрын
Completed all videos of this series. What a journey of around 30-35 days.(from july 1 2023 to august 3 2023), Now i am pretty much confident in DP.Thanks @adityaverma for this amazing series.
@SajidShaikh-ie1ww2 жыл бұрын
Finally completed this awesome playlist...thank you so much @Aditya...we need more people like you...pehle DP ke naam se darta tha...ab lagra hai yahi tha DP... blessed to have you as our teacher ❤️❤️❤️
@monilcharola68732 жыл бұрын
One minor correction according to me :- What will happen if the current node has only one child and it returns the -ve value. The other child is null so it would return 0. And taking maximum of them will result into 0. Thus max(l,r)+curr->val will be equal to ccurr->val (considering the value returned from the existing child is more negative). Thus in the end we would return the curr->val which means we broke the path from leaf to leaf. Consider this part for the node with value 10 and having right child value -25 and left child value 0. For that node max(l,r)+curr->val will be equal to curr->val , which will be returned. Thus breaking the path to leaf node. What we can do is to check before returning. ----------------Method 1--------------------------------------- if(curr->left == NULL) return (r+curr->val); else if(curr->right == NULL) return (l+curr->val); else return (max(l,r) + curr->val); If you don't want to do this work just change the base condition ----------------------Method 2------------------------- if(root==NULL) return INT_MIN -------------------------------------------------------------- I deserve to be wrong. Any suggestions or criticisms are welcomed.
@utkarshjain92212 жыл бұрын
Really Appreciated this bugged me right from the start of the video
@aakanshakowerjani9614 Жыл бұрын
In Method 2, what if the root is a leaf node. In that case both of its child will be null and as per method 2 we will get INT_MIN from both, now when we do max(INT_MIN,INT_MIN)+root.val => this will give unexpected value eventhough it should give root.val only.
@Anand-wi4yb4 жыл бұрын
Finally completed this amazing playlist. I am feeling lucky that I found your videos; otherwise, I would never have learnt DP! Thank you very much for giving us such a wonderful course for free.
@lifewithniharikaa3 жыл бұрын
Just completed the playlist . It changed my whole perception about coding. THANK YOU @Aditya Verma
@nikeshshetty36945 ай бұрын
As everyone else in the comment section has already said, this is the best DP course without a doubt. Thanks a lot for this!
@ishan54564 жыл бұрын
Hands down !! Best series for DP ..... Thnks for all the effort besides your job ..... Please complete the playlist by adding LIS and DP on grids section.... Keep going !!
@TheAdityaVerma4 жыл бұрын
Noted
@ishan54564 жыл бұрын
@@TheAdityaVerma just a suggestion though....... I think if you want to move ahead with different playlists , you could just make intro videos for remaining topics like DP on grids, kadane , lis and Fibonacci advanced.... in which you could just tell about the list of problems that you told about in introduction to dp video ..... This way you could also move ahead with different playlists and this playlist would also be somewhat completed.... !!!
@anonymous-kl1un4 жыл бұрын
@@TheAdityaVerma bhaiii mein kabse wait karr rha tha ki DP ki playlist update hooooo....parr yaar update toh hui magar koi video nahi aaya? Shayad netConnection chala gaya hoga aapka. Ek baar check karlo ki koi video nahi upload hui nayi bhaiijaaaan. Please daaldo DP prr aur videosssss.....meri bohot bhaari request hai aapse ye. Please mere bhagwaan pleasee
@sidhantchandak51524 жыл бұрын
@@TheAdityaVerma Yes, Please keep making more videos. I am a huge fan. I binge-watched all your videos within a week. Your notes are superb!
@ViralAgrawal123214 жыл бұрын
@@TheAdityaVerma Sir, thank you very much for such a great explanation. Please provide at least the problem statement's link of remaining questions which you discussed initially like.. Fibonacci(7) Lis(10) Kadane's Algorithm (6)
@thesaloniguptaa3 жыл бұрын
Finally Completed, learned a lot from this series, can't wait to watch more such content. Keep posting :)
@rahulnagwanshi23483 жыл бұрын
I completed this series in 3 days, feeling much more confident in DP now, learned so much in these 3 days, my confidence went from 0 to 100 real quick I can say lol. If possible please update this series with the leftover problems you mentioned in the first video and also it will be much helpful if u make a dedicated series on Graph. *Thank you ADITYA (The man who made DP easy )*
@ogbuddha78352 жыл бұрын
In 3 days? Seriously?
@rahulnagwanshi23482 жыл бұрын
@@ogbuddha7835 yes bro I was learning in God mode back then
@naive-fleek74202 жыл бұрын
@@rahulnagwanshi2348 from where did u learned graphs and trees?
@rahulnagwanshi23482 жыл бұрын
@@naive-fleek7420 bro unfortunately i couldn't find a dedicated series of graph and trees, i learned it from gfg blogs and take u forward yt channel and few others I don't remember
@soumyachaudhary24682 жыл бұрын
@@naive-fleek7420 codencode channel se pdh le bro graph and for trees mycodeschool channnel ki data structure
@patelchintu64923 жыл бұрын
Finally completed the whole DP series...Very well learned...Thanks to this great man!!!
@mayankpatel67353 жыл бұрын
Finally Completed the series in five days! I have practiced some problems and found them very easy. Thanks a lot for this free material.
@priyajaiwal80722 ай бұрын
Completed entire Dp series. midway through other series. Thank you would not be enough but here i am, Thank you for this gem of a playlist. I am also from 2020 batch like you but the way you explained everything reminded me of that topper friend who explains everything in short and crisp way just 5 minutes before the exam, only here you explained everything in details. I started Dp with thinking it as the most difficult topic ever but tbh if you do enough coding you'll release Array is the one hiding all the weirdness and Dp is actually very chill. Imma update this thread soon. I've read comments, so here to the one who will come in future. "Hey, stick to it, this works wonder!".
@rishikumarjha52812 жыл бұрын
100% done from 1 - 49 >>finishhed the entire series....received tons of knowledge
@alpishjain13173 жыл бұрын
completed the whole playlist in 4 days all of the videos were amazing.The hard part is to keep the concepts in mind,hopefully i'll remember everything.😅
@akshit1094 ай бұрын
me in 5 days... 10 videos/day
@shreeramgoyal843 жыл бұрын
Hands down the best series. Never understood why would we return temp before watching this series especially do on trees. Thank you so much!!!
@184alokkumar22 жыл бұрын
50/50 done. Finally finished the series!🔥🔥
@mansisaxena8154 жыл бұрын
Finally, I have completed this DP playlist. One of the best tutorial I have ever seen. My concepts of DP are cleared now. 👍👍
@mananmakwana43243 жыл бұрын
One of the best series on DP, i had ever found. Thanks!! 💓
@vineetjadhav1785Ай бұрын
Finally i completed this playlist, kudos to those who completed this masterpiece , I was scared of DP but now I can identify and tackle problems on my own and can write up to 90% of the code by myself. Its really helped me to cop-up from my fear of DP. Thanks Aditya Bhai you are a Great Teacher ❤❤
@keshavraghav38962 жыл бұрын
First time I completed the whole playlist on KZbin. now i am going to solve all dp problems on leetcode. Thanks Aditya Verma, you made me realize that Dp, is really interesting.
@valorantrizz2 жыл бұрын
Thank you Aditya bhaiya. You will be remembered till centuries
@preethamnaik74425 ай бұрын
Finished the series, used to think DP as some magical thing that is very tough and complex, but you explained it in the easiest way possible. Thanks Man!🙌🙌
@nikeshshetty36945 ай бұрын
Yes sari pathera
@aoi_sora56674 жыл бұрын
Finally Completed this awesome playlist. Lockdown time used successfully. Thank you very much for this playlist. It is like a gift from God.
@adeshpradhan13144 жыл бұрын
I have gone through so many channels, but your teaching is best, gone through all videos , thanks a lot for this series and efforts
@chaitanyakumar92293 жыл бұрын
i completed 50 videos within a few days it was soo interesting and this is the best series on dp, waiting for more videos :)
@nikhilrajsoni73902 жыл бұрын
finnaly this series is completed,but i dont want to complete this one coz this series was too much fun,i just wanted this series to be super duper long lasting,it was the greatest series ever,thank you bhaiyaa!!!
@idealspeaker1377 Жыл бұрын
Absolutely breathtaking.... GOAT teacher.... hands down sir!
@ayushkoul50652 жыл бұрын
//Maximum Path Sum between any 2 Leaf Nodes /* Points to Note / Corrections : 0. A potential answer is only that path which starts & ends at leaf node...temp can never be a potential answer 1. For leaf nodes we cannot calculate 'ans' or update 'res' because to calculate ans..the current node must have left & right subtree..so that both ends of the path lies on the left and right of cur node. (tbi woh node karta-dharta banega aur potential ans bnega) 2. For node having only 1 child(left or right) we cannot calculate 'ans' (similar to 1) because path's both end must lie one on left & other on right side of current node. (karta-dharta) 3. So for above 2 cases we directly return temp...and we are not calculating 'ans' or updating the 'res'. 4. Here we are asked path between leaf nodes...that means path must start & end at leaf node, so temp will be equal to root->data+max(l,r)...and we cannot ignore both the left (l) or right(r) if they are negative as we did in previous question because then the path will no more be starting from a leaf node. 5. ans=max(temp,root->data+l+r) is wrong...Same reason as temp can never be a potential ans...as it is not ending at a leaf node.. */ //Code:- class Solution { public: int findMaxPathSum(Node *root,int &res) { if (root==NULL) return 0; int lsum = findMaxPathSum(root->left,res); int rsum = findMaxPathSum(root->right,res); if (!root->left and !root->right) //See point 1 & 3 return root->data; if (!root->left) //See point 2 & 3 return root->data + rsum; if (!root->right) return root->data + lsum; int temp=root->data+max(lsum,rsum); //See point 4 int ans=root->data+lsum+rsum; // See point 5 res = max(res,ans); return temp; } int maxPathSum(Node *root) { int res=INT_MIN; int ans = findMaxPathSum(root,res); if(!root->left or !root->right) res=max(res,ans); return res; } };
@Tushar-qd8ow2 жыл бұрын
Very well explained
@varshasingh66272 жыл бұрын
I am not getting your second point if there is on child why we cannot calculate the ans?
@sayantaniguha85192 жыл бұрын
int solve(Node* root, int &maxi) { if(!root) return 0; int leftSum = solve(root->left, maxi); int rightSum = solve(root->right, maxi); // Negative subtree sum cannot be avoided[except for avoiding leaf-node's subtree(s) - which doesn't exist] // For-non leaf node, we've to consider either subtrees & leaf-node wont have any sub-tree(s) int temp = root->data + max(leftSum, rightSum); //if that node isn't answer int rel = root->data + leftSum + rightSum; //if that node is answer int ans = rel; maxi = max(maxi, ans); return temp; } int maxPathSum(Node* root) { // Your code goes here int maxi = INT_MIN; solve(root,maxi); return maxi; } What is the mistake here?
@tk87822 жыл бұрын
Thank You !! big brother . My fear of DP has almost gone now. Credit goes to you only 👏👏.
@dp-ev5me3 жыл бұрын
Have watched all of the dp videos(Binge watched in exam break), found them all incredibly helpful. Thank you sir.
@shubhamjain51323 жыл бұрын
just completed the entire series on DP and it was just awesome. Thank you bro for making my life easy on DP. :) Best source to learn DP
@hemantdhankar1213 жыл бұрын
Hi Aditya, I just finished this series and wanted to thank you for putting in so much effort. You have done amazing work. From the first video to the last video, the passion and enthusiasm in your voice kept me motivated. GREAT SERIES! thank you again.
@AnshKumar-dp1st2 жыл бұрын
Finally completed the series, it will be great if all the topics mentioned in first video were covered, but Still it was a great playlist ♥️.
@vishalsnsingh Жыл бұрын
complete whole playlist today😊 you're good of DP
@adityaagarwal5348 Жыл бұрын
Finally completed this series and I never thought DP was not about 2d array but it is about recursion and how you can find patterns. Always thought of DP as most difficult problem but after recursion + DP series, it looks so much fun.
@MovieLover997 Жыл бұрын
I can't have word to express my feelings on your explanation on this DP series, it's just awesome. I tried to learn DP from many courses and KZbin channels but still no one can explain like you. Thank you for your great effort bhaiya.
@raavimann44724 жыл бұрын
Sir can you please make videos on graphs also. Because after dp the next most difficult topic is graphs which is asked in many interviews. And please sir complete this playlist.This is the best explanation ever of dp.
@Gourav-kl5jt2 жыл бұрын
Finally completed the DP playlist. It was really a great experience and now cleared all the concepts of this playlist.
@rakeshkumaryadav11172 жыл бұрын
Finally when see this lecture Tree topic cleared no one explain better than this thanks for providing such wonderful series
@heenaagarwal67954 жыл бұрын
Hey Aditya, really hoping that you will continue teaching all these complex concepts in such a simple and easy to understand language. Please keep uploading new videos on new topics. Thanks :)
@rajshreegupta44544 жыл бұрын
Finally completed all 50 videos. Thanks for lot for this amazing playlist. Have really started enjoying DP than scaring it!!
@vii2sharma2 жыл бұрын
Thank your Aditya sir...I loved your DP series...
@dharani8871 Жыл бұрын
Thank you 🥺.....i have even improved my problem solving skills.....
@rockington Жыл бұрын
Finally completed this legendary playlist on Dynamic Programming. Thank you Aditya bhaiya😊😊 DATE- 27/2/2023, TIME- 2.20 AM
@mainaksanyal95154 жыл бұрын
Aaj se do week phele dynamic ka dhang ka video dhund raha tha tab ye playlist recommend kiya youtube ne. Jab dekhne baitha tha ek dar the dynamic ke liye. Ab ye hai ki koi bhi problem aa jaye toh darunga toh bilkul nhi. Thanks a lot Aditya. Aur waiting for playlist on Greedy ^_^
@pralaydas64004 жыл бұрын
Sir, your quality of techniques is really awesome, I never see any one who teaches the programming like this, sir one request please kindly upload the other parents problem such as longest increasing subsequence, fibonacci, kadane's , dp on grid and others , it will be very helpful for me and other students also.
@darkknightgaming33752 жыл бұрын
Man, your way of teaching is just awesome!! best playlist for DP ever!!
@himanshutekchandani23632 жыл бұрын
go watch take you forward playlist then you won't find this that much amazing
@sonal9kothari4 жыл бұрын
Thanks @Aditya. I watched this playlist(MCM skipped) in just 2 days, and now I am able to solve many of the medium level DP question from leetcode easily.
@the-sporting-record-book2 жыл бұрын
Done with the playlist Thanks for making me friends with DP problems 👏
@Hereitus4 ай бұрын
finally completed your DP playlist ... you are a legend ....thanks... 😀😀
@AmimulEhsaan2 жыл бұрын
Finally, end of the playlist. Thanks to the LEGEND
@soumikroy46004 жыл бұрын
Humble request to you brother.. Please complete DP playlist.
@priyanshusinghal373 Жыл бұрын
I took my time....but still finished this series now will see.... implementing these in my cp process,revising and practicing more and more questions..... Thanks bhaiya
@akshaychordia87243 жыл бұрын
finally, I have completed this DP playlist. One of the best tutorial I have ever seen. My concepts of DP are cleared now. 👍
@danishakhtar26833 жыл бұрын
finally i completed it now for me DP is like a cakewalk a very big thanks ADITYA you had done such spectacles work for all the coders
@siddhantjain1546Ай бұрын
Feels good to finally complete this playlist! Great content!
@AmanRaj-MNNIT2 жыл бұрын
Thank You for the such great content ,learned a lot and the best part u categorized all the types of questions .
@sahilpatil22402 жыл бұрын
Best DP resource of all time🔥 Thank you sir!
@anchalanju24222 жыл бұрын
Best DP series, now I feel much confident in dp. Thank you for teaching in such a great way.
@sarvottamkaushik37204 ай бұрын
Today reached this last video.... thank you for amazing playlist.
@sandeepm27234 жыл бұрын
For all those folks who got wrong answer on GFG or leetcode here is the correct code just add these base condition and you are good to go aditiya bhaiyaa missed these edge case apart from that solution work perfectly fine: int solve(Node* root,int &answer) { if(root == NULL) { return 0; } if(root -> left == NULL && root -> right == NULL) { return root -> data; } if(root -> left == NULL) { return (solve(root -> right,answer) + root -> data); } if(root -> right == NULL) { return (solve(root -> left,answer) + root -> data); } int ltsum = solve(root -> left,answer); int rtsum = solve(root -> right,answer); int temp = max(ltsum,rtsum) + root -> data; int solution = ltsum + rtsum + root -> data; answer = max(answer,solution); return temp; }
@UECDishaKhattri4 жыл бұрын
Thanks a lot for working code
@tonyriddle76464 жыл бұрын
not working for me.. //here is my code int helperLeafToLeafMaxm(Node* root, int &res){ if(root == nullptr) return 0; if(root->left == nullptr && root->right == nullptr){ return root->data; } if(root->left == nullptr){ return (helperLeafToLeafMaxm(root->right, res) + root->data); } if(root->right == nullptr){ return (helperLeafToLeafMaxm(root->left, res) + root->data); } int lsolve = helperLeafToLeafMaxm(root->left, res); int rsolve = helperLeafToLeafMaxm(root->right, res); int temp = max(lsolve, rsolve) + root->data; int ans = lsolve+rsolve+root->data; res = max(res, ans); return temp; } int maxPathSum(Node* root) { // code here if(root == nullptr) return 0; int res = INT_MIN; return helperLeafToLeafMaxm(root, res); }
@hemanthlishetti75363 жыл бұрын
@@tonyriddle7646 return helperLeafToLeafMaxm(root, res); This is wrong..i.e u are returning temp...instead of returning res; ur modified maxPathSum should be int maxPathSum(Node* root) { // code here if(root == nullptr) return 0; int res = INT_MIN; helperLeafToLeafMaxm(root, res); return res; }
@hemanthlishetti75363 жыл бұрын
Heyy sandeep, can u help me understand why u have included the below extra 2 cases. My argument : is calculating l and r in the next step will take care of these extra 2 cases. But if iam do like that iam getting wrong answer..Iam not getting the exact idea of aditya verma's mistake. if(root -> left == NULL) { return (solve(root -> right,answer) + root -> data); } if(root -> right == NULL) { return (solve(root -> left,answer) + root -> data); }
@suryapratap86802 жыл бұрын
@@hemanthlishetti7536 same doubt and also, why is there a need to check for leaf node, as for a leaf node we will get ltsum and rtsum to be 0, hence tmp will be equal to value at node. which is what he was explaining in @10:35, then stopped mid way.
@Coolharshit1493 жыл бұрын
Hands down to the best DP series ever. Thanku so much Aditya Verma
@ishaankulkarni493 жыл бұрын
reached the end of this brilliant playlist. cat thank you enough for making it!
@priyakoshta71293 жыл бұрын
Finally completed this. Thanks a lot Aditya for this amazing series. I did not get bored and was never lazy to drop this series in between. The way you teach is really interactive and it is not like one way delivery of lectures it is infact a two way interaction.
@Sachinsachin-th4gm Жыл бұрын
Just completed the series...thanks for ur help❤
@srijansingh70703 жыл бұрын
THANKS FOR THIS COURSE ADITYA >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HELPED ALOT >......................
@jayshree75744 жыл бұрын
finally it's over, this playlist will always have a special place in my heart as it taught me a topic like dp, which was seriously scary!!!! Wll miss, "Hi again", anyways going to do a lot questions now!!! So that I can start the heap series. This is one of the best resources, recommending everyone.
@ViralAgrawal123214 жыл бұрын
Sir, thank you very much for such a great explanation. Please provide at least the problem statement's link of remaining questions which you discussed initially like.. Fibonacci(7) Lis(10) Kadane's Algorithm (6)
@ViralAgrawal123214 жыл бұрын
please make this comment reach till aditya verma please it will help us
@tonyriddle76464 жыл бұрын
@@ViralAgrawal12321 nhi degi
@ViralAgrawal123214 жыл бұрын
@@tonyriddle7646 ok..bhai
@manikrangar63573 жыл бұрын
Best ever dp playlist on youtube . Too good bro
@puneethv41383 жыл бұрын
COMPLETED :-)....🔥💥👌.... Waiting for Re-entry of the leader..
@himanshugupta70103 жыл бұрын
finally completed this series . thanks a lot man for this series . now from today I can start solving problems of dp and now I am confident ki m kar lunga
@vasutiwari41873 жыл бұрын
no one : aditya bhaiya posting 50 videos in one day
@rishisharma0930 Жыл бұрын
completed all the 50 videos It is a beautiful series learned a lot and I will suggest you watch the recursion series by Aditya Verma and do a backtracking problem from the interview bit before starting this dp series it will help you a lot Topics covered in this series- 1)0/1 knapsack 2)unbounded knapsack 3)Longest common subsequence(LCS) 4)Matrix Chain Multiplication(MCM) 5)dp on trees Some interesting problems covered 1) Scrambled Strings 2)egg drop problem 3)Maximum Path sum from any node to any node 4)Minimum difference of subset-sum partition of an array
@bikrantanand18114 жыл бұрын
completed whole series..in the very first video u said main jaisa padhaunga koi nhi padhayega..guess u were right.......thanks
@Shri_20024 жыл бұрын
Bhai aapne bola tha saare variations padhayenge please complete kare isko isse pyaari series kahi nahi h youtube pr..
@factsbyalok4 жыл бұрын
Bro Please, make a playlist on Graph. It will really helpful for us.
@laraibanwar16183 жыл бұрын
check take u forward you tube channel grapg series.. u will be good to go
@aayushtalesara91594 жыл бұрын
Sir, thank you very much for such a great explanation. Please provide at least the problem statement's link of remaining questions which you discussed initially like.. Fibonacci(7) Lis(10) Kadane's Algorithm (6)
@ViralAgrawal123214 жыл бұрын
please sir complete it please
@thinkingmad16852 жыл бұрын
Aditya bro sachi me bohot confidence mila yaar , sabhi ko achese code kiya hu bohot acha tarikha tha thankyou 😃😃, Fir aaunga revision karne keliye 🙏🙏
@yashsharma788 Жыл бұрын
Hi, Found this on Google. Hope this help. These are few of the dp patterns along with problems of that particular pattern. Kadane's Algo: 1.Maximum difference of 0's and 1's in a binary string 2.Maximum Sum Circular array 3.Smallest sum contiguous subarray 4.Largest sum increasing contiguous subarray 5.Maximum Product Subarray 6.Largest sum contiguous subarray with only non-negative elements. 7.Largest sum contiguous subarray with unique elements. 8.Maximum Alternating Sum Subarray 9.Maximum Sum Rectangle In A 2D Matrix LIS: 1.Maximum Sum Increasing Subsequence 2.Print LIS 3.Best Team with No Conflicts (LC 1626) 4.No of LIS 5.Increasing Triplet Subsequence 6.LIS having sum almost K 7.Minimum Number of Removals to Make Mountain Array Inspired by Aditya Verma (youtube) Comment if you have other problems to add.
@zero-w1b Жыл бұрын
best playlist for beginners to advance
@codestorywithMIK4 жыл бұрын
Something's wrong with this solution. But with such a good explanation, I figured it out . Thanks
@adityaagarwal6374 жыл бұрын
I think ans variable is wrong, right?
@ShivamKumar-hh9pg2 жыл бұрын
Those who are stuck on Gfg. Try this: int solve(Node* root, int &res){ if(root==NULL) return 0; if(root->left == NULL && root->right == NULL) return root->data; int l = solve(root->left, res); int r = solve(root->right, res); if(root->left==NULL) return (root->data+r); if(root->right==NULL) return (root->data+l); int temp = max(l, r) + root->data; int ans = l+r+root->data; res = max(res, ans); return temp; } int maxPathSum(Node* root) { if(root==NULL) return 0; if(root->left==NULL && root->right==NULL) return root->data; int res = INT_MIN; int x = solve(root, res); if(root->left==NULL || root->right==NULL) return max(res, x); return res; }
@kiranjeetkaur49552 жыл бұрын
can u plz tell why aditya verma code not working ,, left right null is checked in aditya code too .. i cant analyse whats main difference
@codetochange82 жыл бұрын
It was a very nice journey with you Aditya ...I enjoyed this playlist thoroughly. Lots of appreciation for your hard work...Thankss😊
@ankitdubey93103 жыл бұрын
aditya bhai bahut badhiya playlist thi yaar 🎉🎉
@abdurrahmankhan64444 жыл бұрын
Bhai baaki video bhi upload kar do iss playlist ki, dua milegi bachchon se jo abhi tak taras rahe hain DP ki complete series ke liye.... Itna delay na kar bhai, continuation mein break lag jata hai,,, Thanks for your efforts, till now best(est) DP series, but sadly incomplete...
@xCommandoEdits2 жыл бұрын
Finally completed this playlist 😊
@vaibhav2863 Жыл бұрын
series done sir dil se pranaam bhaiya
@jyotipal78213 жыл бұрын
Finally today i complete this series...,i learnt lots of things from here... thanks alot aditya
@DragoonBlod4 жыл бұрын
We all understand that you cannot devote your time in making more videos at a regular pace, so it's a request to provide us with a basic list of topics that you left from the mentioned list in the beginning and list the variations under them. It'd be very helpful to be able to observe patterns in questions.
@093_danishnawab8 Жыл бұрын
Thanx for such efforts and great explaination! finally Completed it today!
@Imajay204 Жыл бұрын
I completed full playlist..... Thank you Aditya Verma sir for such a wonderful content.❤️❤️
@lostgen364 жыл бұрын
0:00 what a way to start off the video 🔥🔥
@rahulnagwanshi23483 жыл бұрын
he has his own way of flexing
@kirtidhanai67724 жыл бұрын
Literally the BEST SERIES OF TREEES that I've ever seeeen. Please make some on LINKED LIST, ARRAY QUEUE as well🥺 I AM SHOOK BY HOW EASY YOU MADE THIS PARTICULAR DS FOR ME. More power to youuuuu🙌🏻