码迷,mamicode.com
首页 >  
搜索关键字:leaf    ( 924个结果
[LeetCode] 872. Leaf-Similar Trees
Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t ...
分类:其他好文   时间:2018-10-08 23:17:21    阅读次数:145
129. Sum Root to Leaf Numbers
一、题目 1、审题 2、分析 给出一棵二叉树,求其从根节点到叶子节点的所有路径中所经过的节点组成的数值之和。 二、解答 1、思路: 方法一、 采用递归进行 DFS,记录从根节点到叶子节点的所有的路径,在对数值进行累加。 方法二、 采用两个 Queue 进行层次遍历,其中 一个 Queue 记录节点, ...
分类:其他好文   时间:2018-10-08 11:26:17    阅读次数:134
[leetcode] Leaf-Similar Trees
Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t ...
分类:其他好文   时间:2018-10-07 20:21:23    阅读次数:131
[CF1042F]Leaf Sets
题目大意:给定一棵$n$个点的树,将叶子节点分为数个集合,使集合里点对最长距离不超过$k$,求最少集合数。 题解:贪心,发现将叶子节点分成集合等于把节点划分集合,答案是一样的。因为一定有一个点,到非叶子节点$p$的儿子的距离比到$p$远。然后发现一个集合一定是连续的(或者连续的一定最优),不然不完全 ...
分类:其他好文   时间:2018-10-05 14:06:25    阅读次数:193
129. Sum Root to Leaf Numbers
1 //New 2 class Solution { 3 public int sumNumbers(TreeNode root) { 4 if(root == null) return 0; 5 return dfs(root, 0); 6 7 } 8 9 public int dfs(Tre..... ...
分类:其他好文   时间:2018-09-23 13:38:24    阅读次数:124
[LeetCode] 156. Binary Tree Upside Down 二叉树的上下颠倒
Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up ...
分类:其他好文   时间:2018-09-22 14:50:45    阅读次数:271
[CF1042F]Leaf Sets
题意:给定一棵$n$个点的树,将叶子节点分为数个集合使集合里点对最长距离不超过$k$,求最少集合数。($n\le1000000$) 首先我们可以想到,这道题并不是让你构造最优方案,因为只要把所有叶子节点的集合任意合并至无法操作,就一定是最优答案了 这个感性理解一下就是那么回事,我一开始做的时候就想到 ...
分类:其他好文   时间:2018-09-22 10:34:46    阅读次数:145
codeforces 1042 F : Leaf Sets
题意:给定一棵树,将叶子节点划分成若干个集合,集合内的叶子节点两两距离小于$K$,问最小划分的集合数。 想歪了,感觉这类题目自己做得好虚啊,不知道为什么能想到这样的思路。 正解就是对于每一个儿子,保存最大距离的叶子,然后排序之后,找到一$R$使得$[1,R]$可以在一个集合内。 然后将$[R+1,s ...
分类:其他好文   时间:2018-09-18 11:16:30    阅读次数:126
742. Closest Leaf in a Binary Tree查找最近的叶子节点
[抄题]: Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. He ...
分类:其他好文   时间:2018-09-06 02:45:10    阅读次数:174
最新的CSS框架
1、Scooter CSS SCSS框架用来提供CSS组件,基础样式和快速静态原型Dropbox,是一个完整的J2EE堆栈框架,需要具备Java和Servlet的基本知识。 2、Leaf CSS 基于谷歌材料设计思想,它包含了一系列的设计元素如图标、字体、调色板、网格线等等。 3、Fox CSS F ...
分类:Web程序   时间:2018-09-05 23:55:35    阅读次数:705
924条   上一页 1 ... 12 13 14 15 16 ... 93 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!