HDU 1325 Is It A Tree?
并査集...
分类:
其他好文 时间:
2014-08-03 10:21:25
阅读次数:
220
问题:将二叉树的所有结点指向他的右边的一个结点分析:对于每一个结点来说,其操作都是一样的,除了他的左儿子指向右儿子外,其左儿子的全部右后辈均指向其右儿子的全部左后辈/** * Definition for binary tree with next pointer. * struct TreeLin...
分类:
其他好文 时间:
2014-08-03 10:12:05
阅读次数:
178
#main {
width: 1200px;
margin-left: auto;
margin-right: auto;
}
#blogTitle {
display: none;
}
分类:
其他好文 时间:
2014-08-03 10:11:45
阅读次数:
186
1.http://sourceforge.net/p/cutycapt/code/HEAD/tree/CutyCapt/svn checkout http://svn.code.sf.net/p/cutycapt/code/ cutycapt-code下载的代码结构cutycapt-code/Cut...
分类:
其他好文 时间:
2014-08-03 01:40:44
阅读次数:
388
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 farthest leaf node.
/**
* Definition for binary tree
...
分类:
其他好文 时间:
2014-08-02 23:32:04
阅读次数:
232
二叉树的深度的概念最值得注意的地方,在于 到"叶子"节点的距离。一般来说,如果直接说“深度”,都是指最大深度,即最远叶子的距离。这里放两道例题,最小深度和最大深度。1. 二叉树的最小深度Given a binary tree, find its minimum depth.The minimum d...
分类:
其他好文 时间:
2014-08-02 23:17:44
阅读次数:
243
题目来源:POJ 2356 Find a multiple
题意:n个数 选出任意个数 使得这些数的和是n的倍数
思路:肯定有解 并且解是连续的一段数
证明:
假设有m个数 a1,a2,a3...am s1 s2 s3...sm为前缀和 s1 = a1 s2 = a1+a2 s3 = a1+a2+a3... sm = a1+a2+a3+...+am
1.如果某个前缀和si%m =...
分类:
其他好文 时间:
2014-08-02 21:01:54
阅读次数:
312
题意:二叉树的最小深度注意 1.当root为空的时候直接返回0,因为MIN赋值很大,所以如果不单独预判的话会返回MIN 2.判断树的深度应该到叶子节点,也就是左右子结点都为空的那个结点 3.树的深度的根节点深度为1class Solution {public: void dfs(...
分类:
其他好文 时间:
2014-08-02 20:39:13
阅读次数:
233
UVA 11488 - Hyper Prefix Sets
题目链接
题意:给一些01串,定义一个P(s)表示:拥有相同长度前缀的字符串个数 * 该前缀长度,求最大的P(S)
思路:Trie,建好Trie树后dfs一遍记录答案最大值
代码:
#include
#include
#include
using namespace std;
const int SI...
分类:
其他好文 时间:
2014-08-02 18:25:04
阅读次数:
202