对称的二叉树
深度优先搜索,进行条件判断即可。
boolean isSymmetrical(TreeNode pRoot) {
if(pRoot==null) return true;
return compare(pRoot.left,pRoot.right);
}
public boolean compare(TreeNode l,TreeNode r){
if(l==null&&r==null) return true;
if(l==null||r==null||l.val!=r.val) return false;
return compare(l.left,r.right)&&compare(l.right,r.left);
}