# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right classSolution: defisSymmetric(self, root: Optional[TreeNode]) -> bool: # print(root.left.val,root.right.val) defSymmetric(a,b): if (a and b and a.val != b.val) or (a and b==None) or (a==Noneand b) : returnFalse if (a==Noneand b==None): returnTrue if (a.val==b.val): result1 = Symmetric(a.left,b.right) result2 = Symmetric(a.right,b.left) if result1 != Falseand result2 != False: returnTrue else: returnFalse return Symmetric(root.left,root.right)