LeetCode: Symmetric Tree
摘要:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).用递归的方法很好做。先比较对应的两个节点数值是否相同,如果相同就看第一个节点的左子和第二个节点的右子是否对称,以及第一个节点的右子和第二个节点的左子。 1 public static boolean isSymmetric(TreeNode root) { 2 if (root == null) return true; 3 else return check(root.lef... 阅读全文
posted @ 2014-01-31 01:18 longhorn 阅读(209) 评论(0) 推荐(0) 编辑