def invertTree(root: TreeNode) -> TreeNode: if not root: return None root.left, root.right = invertTree(root.right), invertTree(root.left) return root
def mergeTrees(t1: TreeNode, t2: TreeNode) -> TreeNode: if not t1: return t2 if not t2: return t1 t1.left = mergeTrees(t1.left, t2.left) t1.right = mergeTrees(t1.right, t2.right) t1.val += t2.val return t1