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

Method isSymmetric3

leetcode/101. Symmetric Tree.py:64–74  ·  view source on GitHub ↗
(self, root)

Source from the content-addressed store, hash-verified

62
63 # iterative(DFS)
64 def isSymmetric3(self, root):
65 if root:
66 stack = [(root.left, root.right)]
67 while len(stack) > 0:
68 p, q = stack.pop()
69 if p and q and p.val == q.val:
70 stack.append((p.left, q.right))
71 stack.append((p.right, q.left))
72 elif p != q:
73 return False
74 return True
75

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected