Lowest Common Ancestor of a Binary Search Tree | Leetcode 235 | Live coding session

preview_player
Показать описание
Here is the solution to "Lowest Common Ancestor of a Binary Search Tree" leetcode question. Hope you have a great time going through it.

Chapters
1) 0:00 Explaining the problem out loud
2) 1:10 Question walkthrough
3) 2:00 Building the algorithm
4) 3:00 Coding it up

For discussion/feedback

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

bro I want to suggest you, you can make a video of length 10 to 12 min, and please explain a little more yes you explained good but you can be better hope you will get my point

deveshkumar
Автор

Today's question is easy. Just come here to see the cute bunny ; )

bellas
Автор

sir why u use return in if condition... please tell me sir 🙏

abhishekranjan
Автор

@Devesh Kumar @coding decoded
class Solution {

public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
while(root!=null){
if(root.val > p.val && root.val > q.val){
root=root.left;
}else if(root.val < p.val && root.val < q.val){
root=root.right;
}else
return root;
}
return root;
}
}

see my solution

sourav