-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/lowest-common-ancestor-in-binary-search-tree
def helper(root, p, q):
if not root: return None
if (root is p) or (root is q):
print('fd')
return root
left_val = helper(root.left,p,q)
right_val = helper(root.right, p, q)
if not left_val: return right_val
if not right_val: return left_val
return root
class Solution:
def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:
return helper(root,p,q)`
```
idk why but when i compare two node object like in the below image root is p or root is q its always retunr false (i tried ==(value check) but that also returns false)
Metadata
Metadata
Assignees
Labels
No labels