2019年3月28日
摘要: LeetCode 二叉树路径问题 Path SUM(①②③)总结 Path Sum II leetcode java 描述 Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals 阅读全文
posted @ 2019-03-28 21:26 反光的小鱼儿 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Path Sum leetcode java 描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the pa 阅读全文
posted @ 2019-03-28 18:12 反光的小鱼儿 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 输入 abc efg. 输出 efg. abc 阅读全文
posted @ 2019-03-28 17:09 反光的小鱼儿 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Balanced Binary Tree 【数据结构和算法】全面剖析树的各类遍历方法 描述 解析 递归分别判断每个节点的左右子树 该题是Easy的原因是该题可以很容易的想到时间复杂度为O(n^2)的方法。即按照定义,判断根节点左右子树的高度是不是相差1,递归判断左右子树是不是平衡的。 根据深度判断左 阅读全文
posted @ 2019-03-28 15:49 反光的小鱼儿 阅读(191) 评论(0) 推荐(0) 编辑
摘要: [Leetcode] Maximum and Minimum Depth of Binary Tree 二叉树的最小最大深度 (最小有3种解法) 描述 解析 递归深度优先搜索 当求最大深度时,我们只要在左右子树中取较大的就行了。 然而最小深度时,如果左右子树中有一个为空会返回0,这时我们是不能算做有 阅读全文
posted @ 2019-03-28 14:55 反光的小鱼儿 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 描述 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthes 阅读全文
posted @ 2019-03-28 14:38 反光的小鱼儿 阅读(137) 评论(0) 推荐(0) 编辑