参考代码:
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Solution:
def help(self, p, q):
if p == None and q == None:
return True
if p and q and p.val == q.val:
return self.help(p.right, q.left) and self.help(p.left, q.right)
return False
def isSymmetric(self, root):
if root:
return self.help(root.right, root.right)
return True