class Solution {
public boolean isSymmetric(TreeNode root) {
if(root == null) return true;
return judge(root.left, root.right);
}
private boolean judge(TreeNode left, TreeNode right) {
if(left == null && right == null) return true;
else if(left != null && right != null && left.val != right.val) return false;
else if(left != null && right == null) return false;
else if(left == null && right != null) return false;
boolean outside = judge(left.left, right.right);
boolean inside = judge(left.right, right.left);
return outside && inside;
}
}
相关文章
- 09-28剑指Offer04 重建二叉树
- 09-28Azure Firewall 非对称路由问题
- 09-28P3884 [JLOI2009]二叉树问题(LCA)
- 09-28236. Lowest Common Ancestor of a Binary Tree 二叉树的最低公共祖先
- 09-28【Leetcode】1123. Lowest Common Ancestor of Deepest Leaves(二叉树最深叶子结点的公共父节点)
- 09-28LeetCode236. Lowest Common Ancestor of a Binary Tree(二叉树的最近公共祖先)
- 09-28UVA-11526H(n)对称性+几何意义+
- 09-28Tree Summing UVA - 112 二叉树
- 09-28Leetcode606.Construct String from Binary Tree根据二叉树创建字符串
- 09-28606. Construct String from Binary Tree 从二叉树中构建字符串