标签:style blog color io div sp log on amp
1: 递归
public class Solution { public boolean isSymmetric(TreeNode root) { if(root == null) return true; return isTwoTreeSymmetric(root.left, root.right); } public boolean isTwoTreeSymmetric(TreeNode node1, TreeNode node2) { if (node1 == null && node2 == null) return true; if (node1 == null || node2 == null) return false; if (node1.val != node2.val) return false; return isTwoTreeSymmetric(node1.left, node2.right) && isTwoTreeSymmetric(node1.right, node2.left); } }
2: 非递归
标签:style blog color io div sp log on amp
原文地址:http://www.cnblogs.com/yuhaos/p/3955164.html