20. Lowest Common Ancestor of a Binary Tree (LeetCode) | DFS Pattern | Binary Tree Tutorials | Code

  Рет қаралды 1,638

Innoskrit

Innoskrit

Күн бұрын

Пікірлер: 14
@aakashverma1124
@aakashverma1124 3 жыл бұрын
At 7:50 (mm:ss) - For storing paths, assuming that the binary tree is not skewed, the space required is O(log N). Otherwise, O(N) space is required in the case of the Skew Tree.
@harshvivek14
@harshvivek14 3 жыл бұрын
Massst bhai 🔥🙌🏻
@ashutoshtiwari5138
@ashutoshtiwari5138 3 жыл бұрын
woww amazing concepts
@hridikasaha9519
@hridikasaha9519 3 жыл бұрын
amazing explanation sir
@shwetachavan584
@shwetachavan584 3 жыл бұрын
Thank you so much sir..🔥🔥
@dsaa2z
@dsaa2z 3 жыл бұрын
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': return self.lca(root,p,q) def lca(self,root,p,q): if root ==None: return None elif root == p or root==q: return root else: left = self.lca(root.left,p,q) right = self.lca(root.right,p,q) if left==None and right==None: return None elif left!=None and right!=None: return root elif left==None: return right elif right==None: return left
@Entertainment-lz5ei
@Entertainment-lz5ei 3 жыл бұрын
The way you are explaining the problem theory and it's solution is so cool . So please continue this process.
@dsaa2z
@dsaa2z 3 жыл бұрын
That was an awesome aproach 🔥🔥🔥
@surabhsaxena7928
@surabhsaxena7928 3 жыл бұрын
To be honest,sir you have made DFS look so easy.👏👏 Simply a masterpiece🔥🔥👌👌
@Innoskrit
@Innoskrit 3 жыл бұрын
😇💝
@amansrivastava834
@amansrivastava834 3 жыл бұрын
Is this playlist covers all topic asked from trees in interview??
@Innoskrit
@Innoskrit 3 жыл бұрын
Yes, few topics are left they will also be uploaded very soon. But you'll get every single topic and question from Tree Data Structure in this playlist.
@RishabhMishra-uw9yb
@RishabhMishra-uw9yb 3 жыл бұрын
Best explanation lekin kaashi itna deemag coding round mein chalta
@Innoskrit
@Innoskrit 3 жыл бұрын
Chalega Boss! Jis din deemaag mein sab code example chhap jayenge, us din chalega.
Lowest Common Ancestor of a binary tree | Leetcode #236
17:29
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 21 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 16 МЛН
L27. Lowest Common Ancestor in Binary Tree | LCA | C++ | Java
14:09
take U forward
Рет қаралды 328 М.
LOWEST COMMON ANCESTOR OF A BINARY TREE I | PYTHON | LEETCODE 236
12:48
Prefix Sum in 4 minutes | LeetCode Pattern
4:13
AlgoMasterIO
Рет қаралды 4,3 М.
L28. Maximum Width of Binary Tree | C++ | Java
22:41
take U forward
Рет қаралды 275 М.
Interview Question: Lowest Common Ancestor
27:07
Byte by Byte
Рет қаралды 14 М.
L15. Check for Balanced Binary Tree | C++ | Java
12:30
take U forward
Рет қаралды 359 М.
L16. Diameter of Binary Tree | C++ | Java
13:47
take U forward
Рет қаралды 379 М.
L37. Morris Traversal | Preorder | Inorder | C++ | Java
23:50
take U forward
Рет қаралды 266 М.
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН