.ui-button { BORDER-LEFT-WIDTH: 0px; OVERFLOW: visible; CURSOR: pointer; FONT-SIZE: 16px; HEIGHT: 40px; BORDER-RIGHT-WIDTH: 0px; ...
分类:
Web程序 时间:
2014-07-24 10:19:03
阅读次数:
252
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
分类:
其他好文 时间:
2014-07-24 10:06:33
阅读次数:
191
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2014-07-24 10:04:33
阅读次数:
214
实现: 1 #ifndef BINARY_SEARCH_TREE_H 2 #define BINARY_SEARCH_TREE_H 3 4 #include "dsexceptions.h" 5 #include // For NULL 6 using namespace st...
分类:
其他好文 时间:
2014-07-24 10:03:33
阅读次数:
398
实现: 1 #ifndef AVL_TREE_H 2 #define AVL_TREE_H 3 4 #include "dsexceptions.h" 5 #include // For NULL 6 using namespace std; 7 8 // AvlTree...
分类:
其他好文 时间:
2014-07-24 10:01:43
阅读次数:
317
题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flatten...
分类:
编程语言 时间:
2014-07-24 09:55:43
阅读次数:
211
题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2-....
分类:
编程语言 时间:
2014-07-24 09:53:16
阅读次数:
219
Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the tot...
分类:
其他好文 时间:
2014-07-24 00:53:27
阅读次数:
198
# include
# include
# include
using namespace std;
int father[1010];
int next[1010];//当前集合的下个元素(包括i)
int pre[1010];//当前集合的上个元素(包括i)
int num[1010];//num[i]当前集合储存的点的个数(包括i)
int vis[1010];
int sum[101...
分类:
其他好文 时间:
2014-07-23 22:39:47
阅读次数:
446
这道题细节真的很多
首先可以想到a和b的最优策略一定是沿着a和b在树上的链走,走到某个点停止,然后再依次占领和这个点邻接的边
所以,解决这道题的步骤如下:
预处理阶段:
step 1:取任意一个点为根节点,找出父子关系并且对这个树进行dp,求出从某个节点出发往下所包含的所有边的权值总和 复杂度O(n)
step 2:从tree dp 的结果中计算对于某个节点,从某条边出发所包含的边的综...
分类:
其他好文 时间:
2014-07-23 22:38:47
阅读次数:
459