mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-31 11:05:36 +00:00
Update 28. 对称的二叉树.md
补充对称二叉树解法中关于两棵子树互为镜像判定的思路说明。
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
## 解题思路
|
||||
|
||||
一棵树对称,等价于根的左右子树互为镜像。比较两棵子树 t1 和 t2 是否互为镜像:根的值相同,并且 t1 的左子树与 t2 的右子树互为镜像、t1 的右子树与 t2 的左子树互为镜像。
|
||||
|
||||
```java
|
||||
public boolean checkSymmetricTree(TreeNode root) {
|
||||
if (root == null)
|
||||
|
||||
Reference in New Issue
Block a user