Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen...
分类:
其他好文 时间:
2014-11-25 12:21:50
阅读次数:
176
和上一题Unique Binary Search Trees一样,这里是要记录所有的可能。存在树里面。这题还是有点难的,我拿了笔写了前几个,推敲了一下,发现如果和上一题一样,存前面的值计算后面的的话会非常复杂,且可能涉及到给一颗数的所有节点加某个值。最终还是放弃用这个方法。可行的二叉查找树的数量是相...
分类:
其他好文 时间:
2014-11-25 00:15:15
阅读次数:
275
题目大意:求一个图的最小标准差生成树。
思路:毫无思路,之后看了题解。居然是一个很厉害的暴力。
一个很关键的地方:枚举平均值,然后根据(a - ave(a))^2将边排序,做最小生成树。所有的标准差最小值就是答案。
但是这是为什么?如果当前枚举的ave(a)并不是选取的边的平均值怎么办?
那么就一定有一个你会枚举到的ave(a)计算之后的标准差要比现在小。
这样基本就可以说明这个...
分类:
其他好文 时间:
2014-11-24 11:56:18
阅读次数:
201
给定n,那么从1,2,3...n总共可以构成多少种二叉查找数呢。例如给定3Givenn= 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ ...
分类:
其他好文 时间:
2014-11-24 00:45:19
阅读次数:
327
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:
其他好文 时间:
2014-11-23 22:56:40
阅读次数:
180
主键和外键主键:是一个索引,帮我们快速的查找,在数据库里拿出一列来作为主键,数据是唯一的不可重复的数据不能为空的数据,减慢新增的数据右键点表,点设计,右击列,设为主键primary key设为主键的关键词外键是一个约束,约束来源与另一个表里面的一列数据,这一列要求是唯一标示的一列unique(把一列...
分类:
数据库 时间:
2014-11-23 15:41:13
阅读次数:
251
题目 Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].思路分析:Pe...
分类:
其他好文 时间:
2014-11-23 13:10:47
阅读次数:
226
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
\ ...
分类:
其他好文 时间:
2014-11-23 09:26:31
阅读次数:
204
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...
分类:
其他好文 时间:
2014-11-23 09:25:10
阅读次数:
174
题意:给出一个图 n x n (2
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2489
——>>数量小,于是,可以枚举取 m 个点的所有情况,对每种情况最一次MST,更新最小值。。
时间复杂度:O(n ^ n * log(n) * 2 ^ n)
#include
#include
#include
#include
using...
分类:
其他好文 时间:
2014-11-22 21:38:15
阅读次数:
277