Invert Binary Tree
Swap the left and right children, and recursively call invertTree on those children. Return root at the end :)
class Solution:
def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
if not root:
return
root.left, root.right = root.right, root.left
self.invertTree(root.left)
self.invertTree(root.right)
return root