← All problems
Invert Binary Tree
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.
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.