null也是镜像对称的树?我佛了
symmetric-tree
http://www.nowcoder.com/questionTerminal/1b0b7f371eae4204bc4a7570c84c2de1
牛客的IDE有些地方真实睿智,凭什么一个null也是镜像对称的。。
public class Solution {
public boolean robot(TreeNode left,TreeNode right){
if(left==null && right==null)return true;
else
if(left==null || right==null)
return false;
return left.val==right.val &&
robot(left.left,right.right) &&
robot(left.right,right.left);
}
public boolean isSymmetric(TreeNode root) {
if(root==null)return true;
return robot(root.left,root.right);
}
}