Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Follow up: Could you solve it both recursively and iteratively?
- Iteratively solution
- Time : O(n)
- Space : O(n)
c++
1 | /** |
- Recursively solution
- Time : O(n)
- Space : O(1) but use call stack O(h)
plaintext
1 | /** |