101.Symmetric Tree
# 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 == None: return True else: return self.mirror(root.left, root.right) def mirror(self, p, q): if p == None and q == None: return True if p == None or q == None: return False if p.val == q.val: ans_l = self.mirror(p.left, q.right) ans_r = self.mirror(p.right, q.left) if ans_l == True and ans_r == True: return True else: return False else: return False