如果一棵二叉树和它的镜像一样,那么它是镜像的。
class Solution: def isSymmetrical(self, pRoot): # write code here return self.Symmetrical(pRoot, pRoot) def Symmetrical(self, pRoot1, pRoot2): if not pRoot1 and not pRoot2: return True if not pRoot1 or not pRoot2: return False if pRoot1.val != pRoot2.val: return False return self.Symmetrical(pRoot1.left, pRoot2.right) and self.Symmetrical(pRoot1.right, pRoot2.left)