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.
For the Lowest Common Ancestor problem, this is also another solution which is as efficient and is actually the CANONICAL solution when it is specifically a binary tree and NOT a binary SEARCH tree.
`
def dfs(root):
if not root:
return None
left = dfs(root.left)
right = dfs(root.right)
if root == p or root == q:
return root
if left and right:
return root
return left if left else right
return dfs(root)
`
The above solution works on the Leetcode website for this problem, but it does NOT work on neetcode
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.
For the Lowest Common Ancestor problem, this is also another solution which is as efficient and is actually the CANONICAL solution when it is specifically a binary tree and NOT a binary SEARCH tree.
`
def dfs(root):
if not root:
return None
`
The above solution works on the Leetcode website for this problem, but it does NOT work on neetcode