思路:
直接分成两部分,左子树和右子树,判断两边再相同位置的时候是否相等就好了。
public boolean isSymmetric(TreeNode root) {
if(root == null) return true;
return isEquals(root.left,root.right);
}
private boolean isEquals(TreeNode left , TreeNode right){
if(left == null && right == null) return true;
if(left == null || right == null) return false;
return(left.val == right.val)&&isEquals(left.left,right.right)&&isEquals(left.right,right.left);
}