L53. Largest BST in Binary Tree

  Рет қаралды 142,556

take U forward

take U forward

Күн бұрын

Entire DSA Course: takeuforward.org/strivers-a2z...
Check our Website:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
#treeSeries #striver #placements

Пікірлер: 326
@takeUforward
@takeUforward 2 жыл бұрын
This is the last video of this series. I hope you enjoyed this. Just a small request: “Please share the series, also you can tag me at Linkedin if you want a give a review for this series, this will do me a world of good” Thankyou 🙏🏻
@yash0270
@yash0270 2 жыл бұрын
Thanks for creating this series.
@akhilesh59
@akhilesh59 2 жыл бұрын
Thank you Bhaiya for this Wonderful series. It was the best DSA based series for me so far. I have already recommended this to all my friends. Now going to start the Graph series 😁..
@sejalrai7358
@sejalrai7358 2 жыл бұрын
completely Lovedd this seriess!! thanks a lotttt
@krishnarajs929
@krishnarajs929 2 жыл бұрын
Thanks bro , It was absolutely great...
@vaibhavkumar526
@vaibhavkumar526 2 жыл бұрын
Hi I feel like the base case value is incorrect, lets say when root is Null, then my tuple returned should have maxNode as -infinity and minNode as +infinity. Then only lets say for a leaf node we can have a value of 1, as a single node is also a BST. Please check this. I tried dry running the code and it didn't work, so I thought I should share this. Well I might be wrong, so please cross verify. I can prove this, lets say, the leaf node is 10, so from the left side the max value would be -infinity and from the right side min value would be +infinity and hence the condition -infinity < 10 and 10 < + infinity would satisfy
@subodh.r4835
@subodh.r4835 2 жыл бұрын
CONGRATS to everyone else who successfully completed this playlist!
@kushagraahire1871
@kushagraahire1871 Жыл бұрын
Did you get a job after learning DSA?
@ultimategyani6412
@ultimategyani6412 Жыл бұрын
​@@kushagraahire1871 yes I got a full stack developer internship in Lockheed Martin( remote ). They asked me two DSA ques in technical round Print spiral matrix Lowest common subsecuence using DP
@kushagraahire1871
@kushagraahire1871 Жыл бұрын
@@ultimategyani6412 congratulations
@ultimategyani6412
@ultimategyani6412 Жыл бұрын
@@kushagraahire1871 thanks brother
@horccruxxxop4184
@horccruxxxop4184 Жыл бұрын
@@ultimategyani6412 what were your projects?
@arpanbanejee5143
@arpanbanejee5143 2 жыл бұрын
Completed the entire FREE KA TREE series! Learnt a lot! Thank you Striver for putting up such quality content!
@bhargav1811
@bhargav1811 Жыл бұрын
11:27 Minimal will be 30 and not 40 !! Thank you striver for this series!! Helped me alot !!
@Area-fd8ht
@Area-fd8ht Жыл бұрын
​@@namashsharma7550tum toh lodu ho fir..😂
@Dontpushyour_luck
@Dontpushyour_luck 9 ай бұрын
completed the entire tree series. Enjoyed a lot! thank you for all the content striver!
@sujoyseal195
@sujoyseal195 2 жыл бұрын
Correction : At 11:30 , the minimum for subtree with root=40 is 30 not 40 . Please provide an edit at this juncture
@abhimanyuraizada7713
@abhimanyuraizada7713 2 жыл бұрын
It made my head spin
@interesting.finds.1857
@interesting.finds.1857 Жыл бұрын
true;
@Now_I_am_all_fired_up
@Now_I_am_all_fired_up Жыл бұрын
True Bhai yrr mera dimag kharab ho gya .......
@vishichaurasiya4427
@vishichaurasiya4427 Жыл бұрын
@@Now_I_am_all_fired_up L lag gaye the mere 😓
@piyushlohiya1977
@piyushlohiya1977 Жыл бұрын
searching for this comment
@aaqilkrishna8840
@aaqilkrishna8840 Жыл бұрын
Just completed this playlist and I would highly recommend it to anyone wanting to learn how to solve Binary Tree and Binary Search Tree based problems from scratch. Thank you for this valuable content !! Cheers ✌❤
@_CSE_PRATHISWARANGR
@_CSE_PRATHISWARANGR 7 ай бұрын
Just completed your amazing tree series Striver and thanks for making such a wonderful series for free :)
@iamnoob7593
@iamnoob7593 4 ай бұрын
Done with free ka tree series. A big thank you striver , I taught i knew trees very well , But when i watched these videos , I had not known most of it.
@abdulrazzak2934
@abdulrazzak2934 2 жыл бұрын
finally completed this amazing free ka tree series and now im taking a break then soon i'll start the next your graph series thanks alot striver for amazing explanation,efficient code ,time complexity an all.thank you so much
@user-nb1ye5tf1r
@user-nb1ye5tf1r 6 ай бұрын
Completed the Tree series in 10 days. Thank you STRIVER for making such a quality content .
@Manishgupta200
@Manishgupta200 9 ай бұрын
This series is superb. Understood all series problem with proper Dry run and solved in multiple ways from Brute to Better to Optimal. Apart from that solved logical tree problem by myself.. Digonal traversal, Path Sum, Sum tree.. and going on..
@aadityakhetan956
@aadityakhetan956 2 жыл бұрын
A great series to learn tree from scratch. Thanks for top notch content. It was really very helpful.
@taranjotsingh7780
@taranjotsingh7780 Жыл бұрын
Completed the entire series today. Feeling much more confident now. Thank you very much Stiver! 😃
@AkashDeep-jp1ts
@AkashDeep-jp1ts Ай бұрын
The hardest tree question I came across but thanks to you, now it's completely clear!!
@noone-pn7yu
@noone-pn7yu 7 ай бұрын
completed whole playlist today, thank striver
@rishabhgupta1222
@rishabhgupta1222 Ай бұрын
Just completed the Tree series playlist....absolutely mindblowing content with highest level of perfection !!!!
@priyanshkumariitd
@priyanshkumariitd 4 ай бұрын
This is one of the best videos of the playlist !!! Thanks Striver bhaiya :)) You made trees easier to understand & visualize...
@arghya_0802
@arghya_0802 2 жыл бұрын
Completed the entire Tree Series. The best one without a doubt!! Finished all the questions & will probably do a couple more. The next destination is DP !!
@shirishprataya4602
@shirishprataya4602 Жыл бұрын
Finally completed this series. Thanks a lot Striver. You have helped a lot. This truly was the best tutorial on trees. 🔥🔥🔥
@shobhitshrivastav9775
@shobhitshrivastav9775 Жыл бұрын
Today I have completed the Free Ka Tree series playlist .It took almost 21 days to complete this series from start to end .I really enjoyed the playlist and learn many new ways of solving tree questions ...thanku striver bhaiya for this top quality content always be thankful to you❤️❤️
@vaishnavigour5777
@vaishnavigour5777 2 жыл бұрын
completed this series today! THANKYOU STRIVER for making such a quality content . Really helped a lot . It took me 6 days to complete this series . It was worth it.
@kartiksrivastava3897
@kartiksrivastava3897 2 жыл бұрын
currently watching the last video it took me 14 days.
@codding32world50
@codding32world50 Жыл бұрын
like how many videos per day
@parthsalat
@parthsalat Жыл бұрын
Did you save/write the codes somewhere, like in a notebook or notion? Because storing codes takes up a lot of my time.
@vaishnavigour5777
@vaishnavigour5777 Жыл бұрын
Yes @parth I have noted them down in a notebook...not the full code but just the pseudo code
@parthsalat
@parthsalat Жыл бұрын
@@vaishnavigour5777 Great! After consulting my "smart" friends, I too have decided to save codes only for difficult questions. For normal questions, I'll just jolt them down in a paper.
@captcha14
@captcha14 Жыл бұрын
Earlier trees and graphs haunt me. Completed this playlist and now questions are solvable. Thank you striver.
@closetoheart6120
@closetoheart6120 Жыл бұрын
bhai are these playlist to understand concept easily ?? and is whole DSA complete here ?
@pushkarchoudhary8276
@pushkarchoudhary8276 Жыл бұрын
@@closetoheart6120 tree playlist are awesome u can follow this according to me
@lifegood6401
@lifegood6401 2 жыл бұрын
It is such a Great Series. More power to Striver. You are the superhero of students like us.
@gouravkushwaha3001
@gouravkushwaha3001 9 ай бұрын
Completed this amazing free ka tree series today
@ashutoshpandey904
@ashutoshpandey904 Жыл бұрын
Finally, Completed this entire series and learnt a lot! It took me around 3 weeks to complete this series and it's totally worth it. Thank you Striver for such quality content, Really helped me a lot !❤❤
@gouravkumar7459
@gouravkumar7459 2 жыл бұрын
Thanks for this amazing playlist, though I knew trees and have done a lot of questions on it, still I wanted to learn new approaches, indeed I learned amazing approaches. Thanks again. :)
@LBK3
@LBK3 Жыл бұрын
Whole tree series is absolutely amazing used to have a lot of confusion on trees and pointers used in them... Completely cleared thanks alott Striver❤
@parthsalat
@parthsalat Жыл бұрын
Thanks for the series...I'd have never learnt BST if it wasn't for this series
@Tahirkhan-hv3jn
@Tahirkhan-hv3jn 10 ай бұрын
**important** if someone is confused while doing dry runwith the solution and example then consider this, There is issue in naming of variables in the code, even though things work well. The maxNode should be replaced by minNode and vice-versa.
@shantipriya370
@shantipriya370 6 ай бұрын
completed the list.. thank you so much..
@Nikita-hv5jm
@Nikita-hv5jm 2 жыл бұрын
finallyy completed the whole series....thanks a lot striver for such a wonderful series on tree...💫
@MdArman_cs
@MdArman_cs 7 ай бұрын
Finally i successfully completed the free ka tree series thanks striver bhaiya🧡
@sulakshsharma8520
@sulakshsharma8520 6 ай бұрын
amazing explanation, thanks!
@momilijaz271
@momilijaz271 2 жыл бұрын
I am in love with this amzing content, definitely gonna follow all other playlists and striver's sheet. Can;t thank you enough for the great content.!
@OmPrakash-kb2wq
@OmPrakash-kb2wq Жыл бұрын
Thank you so much striver. I learnt a lot from this series. Earlier I have very low confidence in Tree and now after your series and practice I leave become very much confident in this portion.
@stith_pragya
@stith_pragya 7 ай бұрын
Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@sautramanivibhuti4597
@sautramanivibhuti4597 8 ай бұрын
Finally completed Thanks striver bhaiya You owe my respect 📈❤️
@youracademicfriend-shashwa1051
@youracademicfriend-shashwa1051 19 күн бұрын
Thankyou Great Explanation!!
@saurabhgautam2697
@saurabhgautam2697 2 жыл бұрын
Completed the whole series ,I was kindaa slow ,took me 3 weeks-1 month,but understood the concepts very well ,as you always say straight into the mind Thankyou bhaiya
@pavannettam8968
@pavannettam8968 Жыл бұрын
The playlist was really helpful to understand trees, thank you so much @striver. I'm sure this is the best tree playlist in the market.
@fakegmail3051
@fakegmail3051 10 ай бұрын
code is not working bro
@huungryyyy
@huungryyyy 14 күн бұрын
bhai kitna pyaara soln likha hai 😍
@tanmaychaudhary2801
@tanmaychaudhary2801 Жыл бұрын
In starting i have got fear from tree topic...and vertical order traversal topic was demotivating for me because at that time I was thinking this(tree and DSA) is not for me....but I continued it and striver bhaiya made it very easy to understand all the topics and now I am feeling very much familiar with this topic...now I am able to think for solutions by myself....thanks a lot striver bhaiya...❣️💫🙌😊🙏
@sandeep-sb
@sandeep-sb Жыл бұрын
Completed the Free ka Tree Series today. Thank you, Striver. I learned a lot from this series. Onto the next one :)
@mdrehankhan3458
@mdrehankhan3458 Жыл бұрын
Thanks man!! this series really helped me to solve tree problems which I found quite difficult while l solving tree questions.
@deepaksaini3986
@deepaksaini3986 Жыл бұрын
Completed successfully!! Now revision is the only thing to do !! and will do it!!
@Nintendo04
@Nintendo04 2 жыл бұрын
finaly completed the entire series and got good concept of tree , thank you for quality content!
@rishabhgupta9846
@rishabhgupta9846 Жыл бұрын
Completed the series in 2 weeks ,thank you Striver for such wonderful playlist.
@anshumaan1024
@anshumaan1024 Жыл бұрын
I took 3-4 weeks 🙂
@vaibhav5269
@vaibhav5269 4 ай бұрын
Hi Striver, Thanks for the free tutorials. I had a small doubt in this problem: If we just exclude 17 from the tree , the remaining tree is a BST, then the size would become 10. Why dont we solve it in this way, It is also a subtree right?
@prateek4-yearb.tech.chemic511
@prateek4-yearb.tech.chemic511 Жыл бұрын
I CAN CONFIDENTLY SAY THAT THIS IS THE ABSOLUTE BEST SERIES ON KZbin FIR TREES; LAST QUESTIONS WERE JUST TOP NOTCH . LOVED IT THANKS STRIVER .
@DSRhymster
@DSRhymster Жыл бұрын
Completed the whole tree series today.... Learnt alot thank you Striver the saviour 🥰🥰
@tejassrivastava6971
@tejassrivastava6971 2 жыл бұрын
solution with cam makes more easier to understand the concept. Thanks!
@abhinavpandey3356
@abhinavpandey3356 2 жыл бұрын
Is the complexity of brute is o(n^3) ie for passing every node to validate * validating *getting size if it is a valid BST ie o(n*n*n) ?please check
@user-dd2rs2tn7c
@user-dd2rs2tn7c 7 ай бұрын
Can this approach work, not wrt TC, but the intuition only ? 1. Find Inorder of binary tree and store it in vector 2. Find the largest sorted substring in that vector Considering each element in tree is unique.
@selvamani.kannan
@selvamani.kannan 4 ай бұрын
yes, it should work. length of longest increasing sub array
@SameerRehan-tt4lh
@SameerRehan-tt4lh Ай бұрын
no
@dank7044
@dank7044 Ай бұрын
It won't work,because we need to return a node as an ans. so the ans would be the complete tree,originating from that node,you cant selectivel keep or exclude any of its child,by your method, you might do this
@abhijeetanand3443
@abhijeetanand3443 2 жыл бұрын
woho finally reached here, thankyou so much striver (Sir/Bhaiya) for this playlist. Many will come through all videos till here and each time you will be blessed by tons 🙌🤩
@abhirupbasu3386
@abhirupbasu3386 Жыл бұрын
Completed the tree series.Thanks for making this amazing tree series.
@AngadSingh97
@AngadSingh97 Жыл бұрын
Hi everyone The link from the SDE SHEET links to Maximum Sum BST in Binary Tree, whereas Striver has solved for Largest BST in Binary Tree. I did not read the question description correctly and was using the approach for the wrong question. Please be careful so that you don't waste 30 minutes like I did, debugging the code and wondering why it's not working. Good to reach the end of Tree Series, thank you Striver bhai. Now on to Graph and DP Problems : ).
@gsmdfaheem
@gsmdfaheem Жыл бұрын
Finally completed the entire Free Ka Tree Series....Thank you so much striver bhaiya for putting in all the efforts...You are the best.
@kashishsharma6809
@kashishsharma6809 2 жыл бұрын
i like brute force also, putting memorization for sub branches.
@AyushiSingh-iy5uf
@AyushiSingh-iy5uf Жыл бұрын
Merge two BSTs is missing in this series, please upload that too! Thanks in advance :)
@sujan_kumar_mitra
@sujan_kumar_mitra 2 жыл бұрын
Thanks for the series, it's really helpful. Waiting for your upcoming series.
@ayushdhiman8128
@ayushdhiman8128 2 жыл бұрын
ky ye series yaha samaapt hoti hai? Thank you for this free playlist ❤
@asit7456
@asit7456 Жыл бұрын
Could you please give notes of the tree series it is incomplete as the notes and the effective explanation makes the series effective.
@mmmm-wm8ci
@mmmm-wm8ci 8 ай бұрын
In right subtree with root 40 how minnode is 40 instead of 30.
@jagjiwanchimkar8106
@jagjiwanchimkar8106 2 жыл бұрын
Mistake at 11:28 , For 40, smallest will be 30 not 40
@ashoksrinivasan4627
@ashoksrinivasan4627 2 жыл бұрын
S
@user-cl3un2qx7s
@user-cl3un2qx7s 12 күн бұрын
495k to 137k itself speaks many things well done striver bhaiya
@user-tk2vg5jt3l
@user-tk2vg5jt3l 3 ай бұрын
Thank you bhaiya
@arpitagupta5834
@arpitagupta5834 Жыл бұрын
In the first example, why isn't 10 included in the BST? (10,5,1,8)
@jaiminsolanki5478
@jaiminsolanki5478 2 жыл бұрын
Thankyou so much Raj Bhaiya for this amazing tree series, extremely useful, it has definitely made our coding roots stronger!!! xD Can't thankyou enough brother!! God Bless you!!
@vivekchatterjee4001
@vivekchatterjee4001 Жыл бұрын
Completed the Series today, developed logic, and made notes, next is the Graph series. Journey never ends✌✌
@sunnykumarsingh7039
@sunnykumarsingh7039 2 жыл бұрын
Today complete the SDE sheet. This was the last question I attempted. Yeah, the order in which I did was according to my comfort, Nevertheless, your content is LIFE-SAVER!!
@Entertainment-hub519
@Entertainment-hub519 2 жыл бұрын
Thanks a lot striver, I completed your whole free ka tree series lectures and I learnt a lot. ❤️❤️❤️❤️
@Manish_Sahu
@Manish_Sahu 2 жыл бұрын
Completed the series🥺🥺 now i can understand that how hard it would be to make such quality content.
@RangerDivine
@RangerDivine 2 жыл бұрын
Finished graph series. Awesome teaching striver!!!
@ayushidalal5488
@ayushidalal5488 Жыл бұрын
Finally completed this series today! Learned a lot. Thanks :)
@ruturaj_dm
@ruturaj_dm 6 ай бұрын
I m not sure how is this solution a O(1) space complexity. We are creating and returning NodeValue object from each node. So for all the O(N) nodes we are returning a new object. If every object is assumed to take O(1) space then we have O(N)*O(1) = O(N) space.
@pqrstwxyz1175
@pqrstwxyz1175 6 ай бұрын
Same doubt...did you get any explanation?...surely has to be O(N)
@sarthakkapoor3764
@sarthakkapoor3764 2 жыл бұрын
How many more episodes left in the tree series?
@ssc_-kn6os
@ssc_-kn6os 2 жыл бұрын
practice link: www.codingninjas.com/codestudio/problems/largest-bst-subtree_893103
@HarshKumar-ip5nr
@HarshKumar-ip5nr 11 ай бұрын
Just an approach. What if we do inorder traversal and find the index of points that violate the increasing vector. Now, we have simultaneously calculated the size of each seperate BST in inorder traversal and return the max one. i.e. suppose the iteration was like: 2, 3, 4, 5, 1, | 6, 7, 8, 10, 12, 13, 9 | 20, 21.. The sizes are : 5, 7, 2 and we return 7. Any thoughts and code?
@sarthakragwan5248
@sarthakragwan5248 10 ай бұрын
This approch fails i also did this one
@HarshKumar-ip5nr
@HarshKumar-ip5nr 10 ай бұрын
@@sarthakragwan5248 why, can you give some insight
@dank7044
@dank7044 Ай бұрын
@@HarshKumar-ip5nr It won't work,because we need to return a node as an ans. so the ans would be the complete tree,originating from that node,you cant selectivel keep or exclude any of its child,by your method, you might do this
@varnit1975
@varnit1975 Жыл бұрын
At size 4 the minimal should be min(40,30) = 30 not 40
@momilijaz271
@momilijaz271 2 жыл бұрын
Problem Link on GeeksforGeeks: practice.geeksforgeeks.org/problems/largest-bst/1/
@mihirsaini592
@mihirsaini592 Жыл бұрын
Loved the entire playlist. Thanks man!
@navyaposham-hx6ix
@navyaposham-hx6ix 19 күн бұрын
I dont understand we can just exclude 14&17 right? If we include 15,16,18,19,20,30,40,50,60 we get a bst of size 9 and that can be our answer
@sauravchandra10
@sauravchandra10 Жыл бұрын
So finally with efforts, I was able to complete this series. Commendable job striver
@atharvacodes3705
@atharvacodes3705 2 жыл бұрын
Thank you for such an amazing Tree series.
@himanshukaushik9223
@himanshukaushik9223 4 ай бұрын
Why we use two classes in ??
@anuraggulati2167
@anuraggulati2167 2 жыл бұрын
thankyou striver for such amazing series i finished this series in just 15 days due to u i am able to understand tree Questions thq 😍👌
@guptashashwat
@guptashashwat 2 жыл бұрын
Commenting to mark, that I have completed this playlist. Thanks Striver!
@shrikantpadhy6125
@shrikantpadhy6125 2 жыл бұрын
Hi Raj, please also make a video on how to find Ntg ancestor of a node
@mukeshmahajan1586
@mukeshmahajan1586 2 жыл бұрын
mm mmm problem problem --striver...Loved it man! 9:50
@codding32world50
@codding32world50 Жыл бұрын
Finally Compelted Yess it took me lot more time than expected... But it is with it.. Thank Youuu So much Striverrr
@amishasahu1586
@amishasahu1586 2 жыл бұрын
Understood. Thank you bhaiya for this amazing series and for all your effort.
@anjalipatel8732
@anjalipatel8732 2 жыл бұрын
Finally completed the tree series, feeling a quite confident in this topic now.
@utkarsh_108
@utkarsh_108 2 жыл бұрын
Let's see when will I finish this Tree Series. Starting this from 03-05-22
@kO_SE__ShivamKumar
@kO_SE__ShivamKumar Жыл бұрын
A really nice explanation again!!!
@harshitjaiswal9439
@harshitjaiswal9439 5 ай бұрын
understood
@patilsoham
@patilsoham 2 жыл бұрын
did not understand: return NodeValue( min(root->val, left.minNode), max(root->val, right.maxNode), left.maxSize + right.maxSize + 1); can someone please explain?
@tejassrivastava6971
@tejassrivastava6971 2 жыл бұрын
they are used to handle the NULL case when min is INT_MAX and max is INT_MIN.
@amanbhadani8840
@amanbhadani8840 2 жыл бұрын
This is condition of a valid BST, that is --- your current root's value is greater than the maximum of all nodes in left and current root's value is lesser than the minimum of all nodes in the right. Then this is considered a valid BST and we simply in min Node we return the minimum of (roots value and the minimum of all nodes in left) and in max Node we simply return the maximum of (roots value and maximum of all nodes in right) and since its a valid case ,in max size we return the sum of all nodes in the left of root +sum of all nodes in right of root+1(root itself) to get the count of total of nodes in a valid BST. Hope, I am able to clear your doubt.
@dakshkalucha5408
@dakshkalucha5408 Жыл бұрын
There is issue in naming of variables in the code, even though things work well. The maxVal should be replaced by minVal and vice-versa.
@bhushanasutkar6135
@bhushanasutkar6135 11 ай бұрын
true
@sakshigupta4793
@sakshigupta4793 Жыл бұрын
Finally completed this Tree Series, Thank you for this amazing content.
@jagjiwanchimkar8106
@jagjiwanchimkar8106 2 жыл бұрын
When will you start Tries series!!
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 33 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 75 МЛН
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32