剑指 Offer 28. 对称的二叉树
递归
public boolean isSymmetric(TreeNode root) { return root == null || isSymmetric(root.left,root.right); } private boolean isSymmetric(TreeNode left, TreeNode right) { if(left == null && right == null) return true; if(left !=null && right != null){ if(left.val == right.val){ return isSymmetric(left.left,right.right) && isSymmetric(left.right,right.left); } } return false; }
我的前方是万里征途,星辰大海!!