My approach was slightly different but i think the underlying intuition is the same. Basically find the centroid of both the graphs. From the centroid, do DFS to find the 2 largest heights (their sum would result in the diamater of the respective tree) and the combined diameter would be sum of the largest height of each tree + 1. We would then take minimum of these values.
Why we cannot use median method , it is giving me wrong answer on 453 test case , if i just join two medians of different trees , please reply @ARYANMITTAL
you will need to track individual diameter of both the trees it could be the case that by joining two medians the path length is still smaller than any one of the two diameters
I guess this one was easier than Problem 3, what do you guys think?
same
Only problem here was to come up with an algo for Diameter 💀💀.
Did not get this intuition of using one extreme to another extreme
yess
Have you gone crazy to go about privatising every video of your channel
My approach was slightly different but i think the underlying intuition is the same. Basically find the centroid of both the graphs. From the centroid, do DFS to find the 2 largest heights (their sum would result in the diamater of the respective tree) and the combined diameter would be sum of the largest height of each tree + 1. We would then take minimum of these values.
nice explanation bro
🥰
My solution failed exactly on the "edge" case mentioned, it cleared my doubt why the answer is 7. Thanks!!!
please make video on leetcode 3202
Done 🫡🤌🏻
why soln giving TLE
Why we cannot use median method , it is giving me wrong answer on 453 test case , if i just join two medians of different trees , please reply @ARYANMITTAL
you will need to track individual diameter of both the trees it could be the case that by joining two medians the path length is still smaller than any one of the two diameters
@@nutrinoflash6132 But how it can be , if am taking median , shoudln't the height is eqaul to half of diameter?
Overkill
@@tirthpatel-t6u ceil(x/2) + ceil(y/2) + 1
this solution gives tle , idk y
No Vedio on 1,2,3 ?
Already live on channel sir🫡😮💨