class Solution:
def isSymmetrical(self, pRoot):
if pRoot == None:
return True
return self.helper(pRoot, pRoot)
def helper(self, p1, p2):
if p1 == None and p2 == None:
return True
if p1 == None or p2 == None:
return False
if p1.val != p2.val:
return False
else:
return self.helper(p1.left,p2.right) and self.helper(p1.right,p2.left)
【二叉树】对称二叉树
最新推荐文章于 2021-11-30 17:39:00 发布