226. Invert Binary Tree
Given the root
of a binary tree, invert the tree, and return its root.
Example :

def invertTree(root: Optional[TreeNode]):
def recurse(n):
if n is None:
return
l = recurse(n.left)
r = recurse(n.right)
n.left = r
n.right = l
return n
return recurse(root)
Comments
Post a Comment