并查集。需要考虑入度。 1 #include 2 #include 3 4 #define
MAXNUM 10005 5 6 int bin[MAXNUM]; 7 int degree[MAXNUM]; 8 int nums[MAXNUM]; 9 10
int find(int x) {11...
分类:
其他好文 时间:
2014-06-02 21:31:31
阅读次数:
219
介绍还有一种平衡二叉树:红黑树(Red Black Tree),红黑树由Rudolf
Bayer于1972年发明,当时被称为平衡二叉B树(symmetric binary B-trees),1978年被Leonidas J.
Guibas和Robert Sedgewick改成一个比較摩登的名字:红黑...
分类:
其他好文 时间:
2014-06-02 20:05:23
阅读次数:
375
先上题目:The Query on the TreeTime Limit: 2000/1000 MS
(Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):
54Accepted Submission(s)...
分类:
其他好文 时间:
2014-06-02 17:23:24
阅读次数:
215
在eclipse下搭建安卓开发环境。感觉这个写得很好,直接借鉴了。随便说一句,如果去安卓官网下的sdkhttp://developer.android.com/tools/index.html就包含了安卓开发集成环境。eclipse也不用下载了。0.0http://jingyan.baidu.com...
分类:
移动开发 时间:
2014-06-02 16:52:36
阅读次数:
249
由于智力的问题,百度之星完全lu不动。。开场看第一题根据题目给的条件我觉得一定是可以构造出来的,题目给的意思颇有鸽巢原理的感觉,于是觉得开场第一题应该就是智力构造题了,想了半个小时,发现完全想不动,于是只能放弃了去想后面的题。然后看第二题的数据结构,树上的询问,支持点修改,询问子树和,还有换根,然后...
分类:
其他好文 时间:
2014-06-02 16:41:08
阅读次数:
257
lca的做法还是很明显的,简单粗暴,
不过不是正解,如果树是长链就会跪,直接变成O(n)、、
最后跑的也挺快,出题人还是挺阳光的。。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#inclu...
分类:
其他好文 时间:
2014-06-01 15:39:05
阅读次数:
256
【题目】
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 1
\ / / / \ 3 2 1 ...
分类:
其他好文 时间:
2014-06-01 15:34:24
阅读次数:
231
【题目】
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 3 2 1
\ / / / \ ...
分类:
其他好文 时间:
2014-06-01 15:33:45
阅读次数:
297
【题目】
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solution is trivial, could you do it iteratively?
confused what "{1,#,2...
分类:
其他好文 时间:
2014-06-01 13:01:23
阅读次数:
279