Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:
其他好文 时间:
2015-02-26 14:44:11
阅读次数:
118
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:
其他好文 时间:
2015-02-25 15:32:26
阅读次数:
109
LCT动态维护MST LCT动态维护MST 我们可以枚举a,然后找从1到n的一条路径使得:这条路径上的b的最大值最小。这个路径肯定在MST上……所以枚举一遍所有的边,动态维护一个关于b值的MST即可。调了半天没出解的原因: rotate写错了……l=c[y][1]==x 我写成了 l=c[z]...
分类:
其他好文 时间:
2015-02-24 23:20:31
阅读次数:
216
LCT 动态维护MST嘛……但是有删边= =好像没法搞的样子 离线记录所有修改&询问,倒序处理,就可以变删边为加边了~ 论如何用LCT维护最小生成树:先搞出一棵最小生成树,然后每次加边(u,v)时,在LCT上询问u->v这条链上权值最大的边,如果这条边权值比新加的边权值要小,则忽略这条新加的边...
分类:
其他好文 时间:
2015-02-24 21:01:24
阅读次数:
245
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm...
分类:
其他好文 时间:
2015-02-24 01:52:56
阅读次数:
152
Given a connected undirected graph, tell if its minimum spanning tree is unique.
Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following properties:
1...
分类:
其他好文 时间:
2015-02-23 15:33:46
阅读次数:
257
??
练习2.41
这道题其实就是书中素数示例的变种,其本质是一样的。因此我们也按照同样的次序来完成这个过程。首先第一步,我们来完成生成3个相异整数构成的三元组。但在上一题中我们已经写出了能够产生2个相异整数构成的二元组了。因此我们只要多产生一个i,让其与产生的二元组结合,便能产生三元组了。那么,开工吧。
(define (unique-triples n)
(fla...
分类:
其他好文 时间:
2015-02-23 09:47:06
阅读次数:
126
??
练习2.40
这道题要我们写一个传入一个整数n然后返回一个序对(i, j)的过程unique-pairs,然后用于上一页的prime-sum-pairs的定义。此时我们要注意在prime-sum-pairs中哪一段代码表达的是这个意思。没错,是flatmap函数。因此我们将其写入到unique-pairs中。
(define (unique-pairs n)
(...
分类:
其他好文 时间:
2015-02-23 09:45:37
阅读次数:
155
Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num...
分类:
其他好文 时间:
2015-02-22 13:21:18
阅读次数:
115
标题:Unique Binary Search Trees II通过率:27.5%难度:中等Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,G...
分类:
其他好文 时间:
2015-02-20 14:05:11
阅读次数:
127