Skip to content

Bug Report for lowest-common-ancestor-in-binary-search-tree #4452

@prashit-vora

Description

@prashit-vora

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy