-
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
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
I think this solution is not optimal but this should also be accepted but getting below error
Traceback (most recent call last):
File "/box/script.py", line 84, in
raise TypeError(f"Your output was {outputNode}, but the expected return type is TreeNode")
TypeError: Your output was None, but the expected return type is TreeNode
if root is None or root == p or root == q:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
if left and right:
return root
if left is not None:
return left
else:
return right
Metadata
Metadata
Assignees
Labels
No labels