Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
- Difficulty: EASY
Input: [1,2,2,3,4,4,3]
1
/ \
2 2
/ \ / \
3 4 4 3
Output: true
Input: [1,2,2,null,3,null,3]
1
/ \
2 2
\ \
3 3
Output: false
- Bonus points if you could solve it both recursively and iteratively.
- Iteration - BFS
- Time complexity:
$O(n)$ - Space complexity:
$O(n)$
- Time complexity:
- Recursion
- Time complexity:
$O(n)$ - Space complexity:
$O(n)$
- Time complexity: