101.对称二叉树
思想:递归
public boolean isSymmetric(TreeNode root) { return isSymmetric(root,root); } public boolean isSymmetric(TreeNode left,TreeNode right) { if(left==null&&right==null) return true; if(left==null||right==null) return false; if(left.val==right.val) return isSymmetric(left.left,right.right)&&isSymmetric(left.right, right.left); return false; }
微信搜索桔子科研或者扫描二维码,第一时间获取编程有趣的知识和最新科研学术成果。
![](https://images.cnblogs.com/cnblogs_com/godoforange/1390071/o_211204035711_qrcode_for_gh_7f100002de19_344.jpg)