MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

Python/100.SameTree.py:13–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11# self.right = right
12
13class 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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected