Skip to content

Commit 1bab0c4

Browse files
Solve : Same Tree
1 parent b93eb38 commit 1bab0c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

same-tree/printjin-gmailcom.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
3+
if not p and not q:
4+
return True
5+
if not p or not q:
6+
return False
7+
if p.val != q.val:
8+
return False
9+
return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)

0 commit comments

Comments
 (0)