solution
recursive
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
def helper(q, p):
if not q and not p:
return True
if not q and p:
return False
if q and not p:
return False
if p.val != q.val:
return False
return helper(q.left, p.right) and helper(q.right, p.left)
if not root:
return True
return helper(root.left, root.right)