leetcode101_对称二叉树
作者:互联网
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;
}
}
标签:right,return,boolean,leetcode101,二叉树,&&,对称,null,left 来源: https://www.cnblogs.com/huangming-zzz/p/15938102.html