226. Invert Binary Tree
Description
Difficulty: Easy
Related Topics: Tree, Depth-First Search, Breadth-First Search, Binary Tree
Given the root
of a binary tree, invert the tree, and return its root.
Example 1:
1 | Input: root = [4,2,7,1,3,6,9] |
Example 2:
1 | Input: root = [2,1,3] |
Example 3:
1 | Input: root = [] |
Constraints:
- The number of nodes in the tree is in the range
[0, 100]
. -100 <= Node.val <= 100
Hints/Notes
- 2023/08/16
- binary tree
- 0x3Fâs solution
Solution
Language: C++
1 | /** |