MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / _Symmetrical

Method _Symmetrical

leetcode/101. Symmetric Tree.py:29–34  ·  view source on GitHub ↗
(self, pRoot1, pRoot2)

Source from the content-addressed store, hash-verified

27 def isSymmetric(self, root):
28 return self._Symmetrical(root, root)
29 def _Symmetrical(self, pRoot1, pRoot2):
30 if pRoot1 and pRoot2:
31 return pRoot1.val == pRoot2.val and self._Symmetrical(pRoot1.left, pRoot2.right) and self._Symmetrical(
32 pRoot1.right, pRoot2.left)
33 else:
34 return pRoot1 == pRoot2
35
36 #iterative(BFS)
37 def isSymmetric2(self, root):

Callers 1

isSymmetricMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected