摘要: Given the following perfect binary tree, 1 / \ 2 3 / \ / \ 4 5 6 7 After calling your function, the tree should look like: 1 -> NULL / \ 2 -> 3 -> NUL 阅读全文
posted @ 2016-02-18 00:24 co0oder 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 是否存在根到叶节点的和等于给定数。 思路:递归。判断左儿子或右儿子是否存在这一路径(sum变为sum-root->val)。 ver0:递归到最后会是叶节点的左右儿子,所以要有root==NULL的判断 1 class Solution { 2 public: 3 bool hasPathSum(T 阅读全文
posted @ 2016-02-18 00:01 co0oder 阅读(156) 评论(0) 推荐(0) 编辑