Lowest Common Ancestor Binary Tree

preview_player
Показать описание

Given two nodes find lowest common ancestor of these 2 nodes in the binary tree
Рекомендации по теме
Комментарии
Автор

the way this was explained in 11 min. I don't think i can find more valuable solutions for this in such a short time anywhere else. Amazing!

okut
Автор

came here after trying to read and failing to understand the leetcode editorial on this question. this was a fantastic explanation, thank you.

solflare
Автор

The space complexity of both the algorithms is O(height), because the recursive algorithm will have function calls on the stack.

Aksionzapion
Автор

I love this guy's multiple walking-through examples on white board!

xuwang
Автор

Wow, great explanation about the algorithm! I appreciated the fact that you gave multiple examples that tested different things!

kevinbaijnath
Автор

Best Video on LCA available on YouTube, Thanks Tushar!

jlecampana
Автор

After i get tired of the logics and code explained by everyone, i do watch your video to understand it in layman and practical way.

sharansingh
Автор

Too good explanation. short and sweet. I can say this particular solution is way better explained than Back ToBack SWE. Thanks and appreciate your effort...

gurupavan
Автор

Thank you, sir! I was confused about this recursive code, but now I understand how it works perfectly!

dianel.
Автор

Another great explanation with a beautiful solution!

dnl_blkv
Автор

The other solution also takes the implicit stack during recursion, so yes it does require the extra space.

robinsoni
Автор

Thank you for covering multiple cases. Other videos didn’t explain as thoroughly as you and didn’t go through many test cases

cosmicgirl
Автор

Optimization note, if the left subtree search yielded the LCA, there's no need to search the right subtree. This can only be avoided by keeping track of how many of the target nodes have been found; it's not sufficient to check if the left subtree search returned a node that is not one of the target nodes, because one of the target nodes may as well be the LCA. For example, 6, and 2.

foreverursabhi
Автор

This is a very useful, well explained, and simple algorithm. Thank you, Tushar.

abdallaelmedani
Автор

This was a great visual walkthrough. Clear and concise.

leonlew
Автор

Thank you! Finally a video that helped me understand the recursive details of the various cases of binary tree

mtjokro
Автор

You are videos are just awesome! Great job! Can't imagine prep without your videos!

cachegrk
Автор

Great job Tushar! Absolutely awesome walkthrough..

decisionguider
Автор

Excellent video/explanation. Your videos make algorithms so much easier.

generalroboskel
Автор

Nicely explained. This is a popular problem statement in Amazon interviews.

learnsharegrow