思路:
判断二叉树是否对称可以转化为判断左子树和右子树是否对称。
boolean isSymmetrical(TreeNode pRoot) { if(pRoot==null)return true; return help(pRoot.left,pRoot.right); } boolean help(TreeNode left,TreeNode right){ if(left==null&&right==null)return true; if(left!=null&&right!=null&&left.val==right.val) { return help(left.left,right.right)&&help(left.right,right.left); } return false; }