2014年11月27日
摘要: 这里是给定一个数,判断是不是对称的,即根据根画一竖直线对折重合一样。For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ ... 阅读全文
posted @ 2014-11-27 19:48 higerzhang 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 判断两个树是不是相等。思路:递归。当前节点相等,且他们左子树和右子树都相等。class Solution {public: bool isSameTree(TreeNode *p, TreeNode *q) { if (!p) return !q; if (... 阅读全文
posted @ 2014-11-27 00:34 higerzhang 阅读(298) 评论(0) 推荐(0) 编辑