| 11 | # self.right = right |
| 12 | |
| 13 | class Solution: |
| 14 | |
| 15 | def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: |
| 16 | result = [] |
| 17 | self.preorder(p, q, result) |
| 18 | return min(result) |
| 19 | |
| 20 | def preorder(self, p, q, result): |
| 21 | if not p and not q: |
| 22 | result.append(True) |
| 23 | return |
| 24 | if not p or not q: |
| 25 | result.append(False) |
| 26 | return |
| 27 | if p.val != q.val: |
| 28 | result.append(False) |
| 29 | if p.val == q.val: |
| 30 | result.append(True) |
| 31 | self.preorder(p.left, q.left, result) |
| 32 | self.preorder(p.right, q.right, result) |
nothing calls this directly
no outgoing calls
no test coverage detected