(self, root)
| 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 |