day10笔记
1.题目描述
2.代码构思(debug)
class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
if not root:
return True
def isMirror(left,right):
if not left and not right:
return True
if not left or not right:
return False
if left.val != right.val:
return False
leftequal = isMirror(left.left,right.right)
rightequal = isMirror(left.right,right.left)
return leftequal and rightequal
return isMirror(root.left,root.right)