-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Bug Report for https://neetcode.io/problems/same-binary-tree
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
The following code passes and is accepted:
def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
if p == None and q == None:
return True
if (p == None and q !=None) or p!=None and q == None:
return False
if p.val != q.val:
return False
if (p.right == None and q.right != None) or (p.right != None and q.right == None):
return False
if (p.left == None and q.left != None) or (p.left != None and q.left == None):
return False
if p.right and q.right:
return self.isSameTree(p.right, q.right)
if p.left and q.left:
return self.isSameTree(p.left, q.left)
return True
This should fail and fails the test case
p=[1,2,4]
q=[1,3,4]
Please add this test case to the backend test cases to correct this.
Thank you so much!
Metadata
Metadata
Assignees
Labels
No labels