时间限制:0.75s空间限制:4M题意: 在一颗树(最多500000个节点)中,可以对节点染色,但是一个节点染了色后,它的父节点和兄弟节点都不能再染了,求最大的染色节点数,并输出所有染色节点。Solution: 一开始写了一个树形DP 后来看到有人说题目的输入是从上到下的。。。直接倒过来...
分类:
其他好文 时间:
2014-09-10 17:14:10
阅读次数:
142
Just installed the KDE on my Ubuntu, and the Internet explorer comes with the KDE is the Konqueror, however the first time I was using the Konqueror found it cannot display the Chinese properly, all becomes gubbish characters, found the solution by google...
分类:
其他好文 时间:
2014-09-10 12:36:20
阅读次数:
253
1 public class Solution { 2 public boolean search(int[] A, int target) { 3 int low=0, high=A.length-1; 4 while (low=target) low=m...
分类:
其他好文 时间:
2014-09-09 23:02:39
阅读次数:
217
O(n)时间,O(1)空间对二叉树进行前序、中序、后序遍历。详细讲解看参考。public class Solution { public static void morrisPreorder(TreeNode root) { TreeNode cur = root; ...
分类:
其他好文 时间:
2014-09-09 22:58:39
阅读次数:
425
Problem Description:
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution se...
分类:
其他好文 时间:
2014-09-09 21:35:29
阅读次数:
281
1 public class Solution { 2 public int search(int[] A, int target) { 3 int low=0, high=A.length-1; 4 5 while (lowA[mid] ...
分类:
其他好文 时间:
2014-09-09 21:30:09
阅读次数:
178
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],...
分类:
其他好文 时间:
2014-09-09 21:17:39
阅读次数:
205
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:
其他好文 时间:
2014-09-09 19:57:29
阅读次数:
237
rpm-->yumxml,json:半结构化的数据yum仓库综合那个的元数据文件primary.xml.gz所有RPM包的列表依赖关系每个RPM安装生成的文件列表filelist.xml.gz:当前仓库中所有RPM包的所有文件列表other.xml.gz:额外信息,RPM的修改日志repomd.xml:记录的是上面三个文件的时间戳和校..
分类:
其他好文 时间:
2014-09-09 18:31:19
阅读次数:
214
思路: 逐步查找。当出现不同时,如何回溯是关键。
Solution B 与经典 KMP 算法:
next[0] = 0; (0 位置不能匹配,下次还从此位置开始匹配)
next[pos] = (P[next[pos-1]] == P[pos] ? next[pos-1]+1 : 0);
分类:
其他好文 时间:
2014-09-09 15:04:38
阅读次数:
160