这题的思路也是递归(递归在二叉树中很重要哦)。
class Solution { public boolean isSymmetric(TreeNode root) { if (root ==null){ return true; } return symmetric (root.right,root.left); } private boolean symmetric(TreeNode right,TreeNode left){ if(left == null && right == null) return true; if(left == null || right == null) return false; return (left.val==right.val)&&symmetric(left.left,right.right)&&symmetric(left.right,right.left); }}