Invert a Binary Tree
Problem Invert a binary tree — mirror it so every node's left and right subtrees are swapped — and return the root.
Input / Output
- Input:
rootof a binary tree (may be null). - Output: the root of the mirrored tree.
Constraints
- 0 ≤ nodes ≤ 100.
Example
- [4,2,7,1,3,6,9] → [4,7,2,9,6,3,1].
added …