Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following is not:
1
/ \
2 2
\ \
3 3
Note:
Bonus points if you could solve it both recursively and iteratively.
题意:给定一个二叉树,判断它的镜像是不是它自己。也就是对称。
本文探讨了如何检查一个二叉树是否与其镜像相同,即是否对称。介绍了递归和迭代两种方法来解决这个问题,并给出了具体的实现思路。
391

被折叠的 条评论
为什么被折叠?



