101. 对称二叉树 1.题目描述及示例 题目描述 给定一个二叉树,检查它是否是镜像对称的示例 2.题解思路及代码 思路 简单,略代码 int tag=0; public boolean isSymmetric(TreeNode root) { if (root==null) return true; TreeNode left=root.left; TreeNode right=root.right; isSame(left,right); if (tag==1) return false; return true; } public void isSame(TreeNode root1,TreeNode root2) { if (root1!=null&&root2!=null) { if (root1.val!= root2.val) { tag=1; return; } else { isSame(root1.left,root2.right); isSame(root1.right,root2.left); } } else if (root1!=null&&root2==null) { tag=1; return; } else if (root1==null&&root2!=null) { tag=1; return; } }