101. 对称二叉树
给你一个二叉树的根节点 root , 检查它是否轴对称。
示例 1:
输入:root = [1,2,2,3,4,4,3]
输出:true
示例 2:
输入:root = [1,2,2,null,3,null,3]
输出:false
class TreeNode:def __init__(self, val=0, left=None, right=None):self.val = valself.left = leftself.right = rightdef check(left, right):if left is None and right is None:return Trueif left is None or right is None:return Falseif left.val != right.val:return Falseelse:return check(left.left, right.right) and check(left.right, right.left)def isSymmetric(root):if not root:returncheck(root.left, root.right)