a very wise man once said "aaj ke baad me kabhi hypothesis par baat nhi krunga", maine first time dekha es topic par kisi ne baat ki, you are really great brother, keep it up
@0anant04 жыл бұрын
46 of 50 (92%) done! Very good explanation! I have seen quite a few tree-related code and many of those fall into this pattern, though they try to return values in a host of diff ways. This pattern is uniform and clean.
@SurjitSingh14-c6i3 жыл бұрын
Which one left in bw
@jayshree75744 жыл бұрын
you raised the standard of teching coding, every other video now looks lame
@divyaa.the.explorer4 жыл бұрын
seriously so true....hope this channel grows.
@satyamrajsingh73784 жыл бұрын
Sir your videos are A masterpiece, you will soon takeover the other youtubers
@TheAdityaVerma4 жыл бұрын
I hope so brother !! Right now it's only 244 subscribers and 4.3k views. Share Please and help this channel grow !!
@code_life48354 жыл бұрын
@@TheAdityaVerma 5 months ago you had 244 subscribers, Now you have 20.5K subscribers. You are really changing the standard of teaching. Thank you for such an awesome content!
@abhaydesalli73444 жыл бұрын
@@TheAdityaVerma It's 28.6k subscribers today. Hats off man!
@techykush71923 жыл бұрын
@@abhaydesalli7344 and today 46k subscribers amazing man😍😍
@ashadahmad64933 жыл бұрын
@@techykush7192 now 47k subscribers 😍😍😍
@Rakeshmishra-gx8ii3 жыл бұрын
LIT intro with revolving pen on fingers.
@divyachoudhary59384 жыл бұрын
Ur videos are extremely awesome and I have recommended it to all my friends... Just wanna say I love the way u teach and the way u rotate the pen.... 😅
@TheAdityaVerma4 жыл бұрын
Thanks Divya !
@dhawalbhende12504 жыл бұрын
@@TheAdityaVerma full simpbazi
@abhisheksahay20384 жыл бұрын
Sir graph k liya bhi kuch video upload kariya..
@k.chandanapriya40044 жыл бұрын
sir i have shared it with my friends also.. all of us are eagerly waiting for the graphs and backtracking. please upload it soon sir.
@RandomShowerThoughts Жыл бұрын
the beginning of the video perfectly summed up how to write recursive code for trees
@bloggerayush855010 ай бұрын
"Meko nhi pta kaise answer laake dega Left and right se , bss laakr dega.." is also know as Recursion Leap of Faith 🤣🤣
@ayushkumarsingh82124 жыл бұрын
eik baaar mein aapki saari videos dekh li, DP pehle bhi karta tha mai but aapne nazariya hi badal dia. Eik playlist Array pr bhi nikal do i think placement mein vo bhi bahut important hai
@adarshverma0134 жыл бұрын
Awesome content sirrrr!!!!!! i can't believe i solved todays leetcode challange(of 30day challange) question i.e. maximum path sum just by watching this video. Thanks a lottttt for creating such awesome contents for us!!!!
@TheAdityaVerma4 жыл бұрын
Thanks Adarsh, Dont forget to share if you like the content and help the channel grow !!
@learncoding56332 жыл бұрын
The content and explanation is awesome please post more videos
@kartiksaini56193 жыл бұрын
BHAI VIDEO SHURU HONE SAI PHLE MAI APKI VIDEO LIKE KARDETA HUN (DIL MANTA HI NAHI...BINA LIKE KIE DEKHNE KO )..BAHUT HI ACHA LAGTA HAI....THX FOR ALL THE EFFORT
@debasishparamanik65273 жыл бұрын
Hi, I think ans variable should be updated like this, ans=max(temp-1,1+l+r). Because it will be maximum of left diameter, right diameter and path through root.Please clarify.
@bikeshregmi2392 Жыл бұрын
I am still confuse on why at last we are returning Temp. Thank you!!
@udaykumar-iu2ok4 жыл бұрын
Thanks for simplified solutions
@TheAdityaVerma4 жыл бұрын
Welocme, Share and subscribe.
@lucy-uo6bt4 жыл бұрын
run dfs 2 times -> o(n) :1st to get farthest node and then to calulate the farthest from that node
@mickyman7533 жыл бұрын
how can we calculate the farthest node after gettin ghold our node
@pavankalyan43592 жыл бұрын
Take a bow, this is really a great video and this guy made DP look very easy.
@aakanshasoni57984 жыл бұрын
It would be really helpful if you can help with the recursion code as well. BTW you have done a big favour on us by uploading these videos it made coding simple. Thanks a lot.
@faizan3464 жыл бұрын
max(temp=1+max(L,R) , relation=1+L+R), dont we get 1+L+R here every time. i think we return temp and store res = max(res,1+L+R);
@tusharshaily4 жыл бұрын
for this question L and R will always remain positive : so there is no use for ,max here . But for other questions we have to look for L and R which can be negative ;
@faizan3464 жыл бұрын
@@tusharshaily thx i understood that, when i had watched the next video.
@patel1681 Жыл бұрын
This is awesome. Thank you for sharing the knowledge.
@prashantranjan37774 жыл бұрын
Hi Aditya , Your videos are awesome. Kindly make videos on Tree and LinkList
@mohakmalhotra857 ай бұрын
Amazing, explained it so well brother
@tanmaykumar92773 жыл бұрын
12:32 Hum res = 0 kyun nahi initialize karr sakte? because vaise bhi jaise hi res solve function mein jaayega toh uski minimum(or worst condition mein) value 0 ho jaayegi... toh humne res = INT_MIN kyun kiya?
@rajsaraogi Жыл бұрын
the way he is teaching is like shortcut without any reason :(
@tanmaytyagi70313 жыл бұрын
pair func(TreeNode * root) { if(root == NULL) return {0,0}; pair a = func(root -> left); pair b = func(root -> right); int h = 1 + max(a.first , b.first); int d = max(a.second , max(b.second , a.first + b.first)); return make_pair(h , d); } int diameterOfBinaryTree(TreeNode* root) { return func(root).second; } // pair (first,second) : first -> height , second -> diameter // is my code inefficient? for the calculation of diameter of Tree
@ankitjhunjhunwala98953 жыл бұрын
your videos should be taught as fundamentals in college, Great work bro ! Apke charan kanha hai :)
@kartikeyjajoo84993 жыл бұрын
The more you think about the hypothesis section, the more chaotic your thoughts become
@shubhamsingh-gb5zh4 жыл бұрын
Amazing explanation 👌❤️
@167shivamrai23 жыл бұрын
Really appreciate your efforts , that helps all of us. I think govt. should give job to teachers like him who are devoted and dedicated to their work . The govt should pay them salary double which are getting in MNCs , to teach the youth . This man skills and presentation work is so good , then those of NPTEL lecture teachers. Man like him want to teach and understand the importance of basics taught to young programmers , but can't balance all time to do so because of their job roles. I wholeheartedly wish teachers like him should given importance by govt. as they are nourishing the youth with great programming skills . I don't have free time to write such a long comment, but this man deserves appreciations from all . If you like this pls share this on linked in . With mentioning name of teachers like him who should be given vote of appreciations.
@kalagaarun96384 жыл бұрын
0:00 aise hi karte karte kitna kitna pen ka ball tod diya maine !!
@Vikash_Art4 жыл бұрын
Bro please upload the bitmasking with dp
@suhelalam26865 ай бұрын
I am still confuse on why at last we are returning Temp.
@tushnaeduljee14914 жыл бұрын
Amazing video :)
@codingwithanonymous8903 жыл бұрын
DP king =Aditya Verma
@Pranshul20023 жыл бұрын
Thank you
@mightygerman Жыл бұрын
Thnx a lot sir...
@rahulyadav-xn5mt3 жыл бұрын
There is no need of variable ans, as 1+l+r >= 1+max(l+r) and l,r>=0;
@affiliatastic12692 ай бұрын
was going to comment same only
@yobro70514 жыл бұрын
bro digits dp v padha do n plz..
@hardikmittal72913 жыл бұрын
0:00 pr pen ghumte hue dekh kr lga ki pen ghumane ka tutorial bnaya h... 😂😂
@sakshamsrivastava62803 жыл бұрын
This is beautiful
@SmokyBigSmoke4 жыл бұрын
Thank you so much bro
@ashishsoni31874 жыл бұрын
Mera aditya bhai jindabad
@namansharma22034 жыл бұрын
Aditya sir, can we have this analogy as a full udemy course??Please
@kunalkumarbarman96104 жыл бұрын
Sir left dp ki playlist kb ayegi?
@aravindasaigadamsetty64133 жыл бұрын
aaj se bc matlab base condition
@akshayshikhawat63423 жыл бұрын
content is very good, try to make vedios on leetcode problems solutions.
@navneetkaur41253 жыл бұрын
bhot badhiyaa!!
@babai21962 жыл бұрын
return temp keu karrehehe last me ! samajh nehi aya
@mominmaster25574 жыл бұрын
in 12:55 you have written ans = max(temp , 1+r+l), but 1+r+l will be always greater than temp. as temp= 1+max(r,l). So I think ans = 1+r+l ; correct me if I am wrong.
@0anant04 жыл бұрын
This is just a template for tree-related DP problems, and not solution for count of nodes, path sum, diameter, etc. -- so check specific problems in later videos.
@tanmaykumar47844 жыл бұрын
OP bhai.
@abhisheksuryavanshi96754 жыл бұрын
Bhai please upload new videos!
@Rahul-vl1no2 жыл бұрын
How answer will send from lower node to higher node? It's my curiosity form last 3 year
@rajsaraogi Жыл бұрын
What is the reason to set value of res = Integer.MIN ?
@Amanali-rl9hw Жыл бұрын
as we are always trying to find the max value of result in each iteration that is why we set it to min(a negative number, and diameter cannot be negative as distance cannot be negative) at the beginning so that even smallest ans like 1/0 is possible
@namanftw86414 жыл бұрын
sir plzzzzzzz graph pe video laooooo
@mukuldaftary92303 жыл бұрын
bahut sahi
@vaibhavpandey56153 жыл бұрын
sir why you apply ans=max(temp,1+l+r) step i did not understand it.
@abhinandanb35913 жыл бұрын
kena, its just a template
@himanshunegi52284 жыл бұрын
nice
@rahulsaxena91034 жыл бұрын
can someone explain why we returned temp? There might be a case when 'ans' is greater. We should return ans in that case. Why we are just returning temp?
@deveeshmusic50454 жыл бұрын
You're right. We should return ans. Perhaps he made a mistake, or both of us are wrong xD
@praxlannister78594 жыл бұрын
Both are wrong ans is in res and wo update ho chuka hai before returning
@rishabsinha87494 жыл бұрын
He returned temp because ans is alredy updated and we require temp for further process i.e. l+r+1 means the diameter but for further process we don't require ans rather we require either the left subtree height or the right subtree height whichever is maximum plus 1 that's why temp is returned
@rishabsinha87494 жыл бұрын
int solve(Node* root, int* ans) { if(root == NULL) return 0; int l = solve(root->left, ans); int r = solve(root-> right, ans); *ans = max(*ans, l+r+1); return 1+max(l,r); }
@David-mk8kh Жыл бұрын
4:44 I promise to you bro 🤣🤣🤣
@babbarutkarsh77704 жыл бұрын
🔥🔥🔥
@saliq009711 ай бұрын
" agar base condition smjh na aye to if(root == null )return 0 kaam chal jaega "
@anirudhsridhar79003 жыл бұрын
The bird view From 4000 feet height 😅
@vinaysarilla48894 жыл бұрын
Bro Please add Backtracking......
@anmolcoolsinha4 жыл бұрын
Can anyone give the java alternative?
@0anant04 жыл бұрын
use can use int[] res = new int[1] and store the value in res[0], and pass int[] res as param. Or define a class variable m_res. Or define a full-fledged class Result that has 'int res' as data member and pass an obj of that as param. You can also use AtomicInteger that can be passed just like a reference -- I think it has get/set methods.
@ani683 жыл бұрын
91.4k now
@bismeetsingh3524 жыл бұрын
Bhai ye video samaj me nai aya,wo relation kya tha jo ans me dala,kuch samja nai.
@mehershrishtinigam54492 жыл бұрын
i did a dp on tree question without even realising it a dp on tree q lol
@ankitdubey93103 жыл бұрын
normal people: i am suffering from cold and fever let me sleep , le aditya verma: yahi to time hai video banane ka legend !!