这道题一眼看上去就是一个递归的算法,对于一棵树,分三种情况,包括根、仅左子树、仅右子树,递归的确认最大值,其中第一种情况(路径中包含根)分析可知它会一直包含根,后两中就复杂点,需要一直递归处理每颗子树。代码如下:int maxPathSumWithRoot(TreeNode *root) { if ...
分类:
其他好文 时间:
2014-08-30 21:43:10
阅读次数:
307
Color a Tree
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1068 Accepted Submission(s): 349
Problem Description
Bob is very in...
分类:
其他好文 时间:
2014-08-30 17:49:09
阅读次数:
141
- For now, CodeBlocks doesn't privide binary packages for CentOS7.(http://www.codeblocks.org/downloads/26#linux64)- In this thread(http://forums.codeb...
分类:
其他好文 时间:
2014-08-30 17:45:39
阅读次数:
237
树形DP。。。
B. Appleman and Tree
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Appleman has a ...
分类:
移动开发 时间:
2014-08-30 15:11:29
阅读次数:
246
一棵树上有K个黑色节点,剩余节点都为白色,将其划分成K个子树,使得每棵树上都只有1个黑色节点,共有多少种划分方案。
个人感觉这题比较难。假设dp(i,0..1)代表的是以i为根节点的子树种有0..1个黑色节点的划分方案数。
当节点i为白色时,对于它的每个孩子的节点处理:
求dp(i, 0)时有:
1,将该节点与孩子节点相连,但要保证孩子节点...
分类:
移动开发 时间:
2014-08-30 12:43:49
阅读次数:
265
C - Problem C
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
SubmitStatus
Problem Description
Consider an infinite complete binary tree where the root nod...
分类:
其他好文 时间:
2014-08-30 08:49:29
阅读次数:
232
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2014-08-30 02:22:18
阅读次数:
244
阅读导航提高性能索引 B-tree 索引 Hash 索引 其他类型指针索引百利无一害索引对于接触过数据库的人,都不会很陌生,但是说实话,也不一定很熟悉。先来介绍下索引的优点。提高性能现在有一个数据库表[Words],有[WordID],[WordPage],[[WordName],[WordPron...
分类:
数据库 时间:
2014-08-30 02:20:38
阅读次数:
360
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
具体一位一位地加就行了,考虑进位的问题。还有最后记得把生成的string反过来再返回,因为我们是从最低位开始加的。
public class Solu...
分类:
其他好文 时间:
2014-08-30 01:16:58
阅读次数:
286
把前段时间做的东西整理一下。主要是树形菜单和grid面板的结合。选中左边机构菜单的节点,右边grid面板显示该节点下的信息。首先是建立treestoreExt.create('Ext.data.TreeStore', { autoDestroy: true, proxy:...
分类:
Web程序 时间:
2014-08-30 01:15:40
阅读次数:
325