题目
https://leetcode-cn.com/problems/symmetric-tree/
代码python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if root is None:
return True
def temp_tree(left,right):
if left is None and right is None:
return True
if left is not None and right is not None and left.val ==right.val:
return temp_tree(left.left,right.right) and temp_tree(left.right,right.left)
return False
return temp_tree(root.left,root.right)