class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
def cur(L, R):
if not L and not R: return True
if not L or not R or L.val != R.val: return False
return cur(L.right, R.left) and cur(L.left, R.right)
if not root:
return True
return cur(root.right, root.left)
剑指offer28:对称二叉树 python题目描述解法题目描述解法class Solution: def isSymmetric(self, root: TreeNode) -> bool: def cur(L, R): if not L and not R: return True if not L or not R or L.val != R.val: return False return