← All problems

Invert Binary Tree

Easy treesrecursion LeetCode ↗
Invert a binary tree: transform it into its mirror image, swapping every node's left and right children. Solve it both recursively and iteratively and compare the approaches.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(h)

Common pitfalls

  • Swapping after recursing into the wrong child
  • Null checks

Your solution

Log in to save your code and track progress.