Question

Given the root of a binary tree, invert the tree, and return its root.

This is atree question.

Idea

  • Use a recursive DFS solution
  • Base case: if root is None, return
  • Swap left and right
  • Recursively invert left and right children

Solution