Invert binary tree
Question
Invert a binary tree.
Example
1 | input: |
Solution
We just need to swap left and right at each time, at the end we just need return root.
Code
1 | // time:O(n) space:O(n) |
Invert a binary tree.
Example
1 | input: |
We just need to swap left and right at each time, at the end we just need return root.
1 | // time:O(n) space:O(n) |