4Sum问题:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the ...
分类:
其他好文 时间:
2015-04-01 21:45:11
阅读次数:
92
The set [1,2,3,…,n] contains a total of n!
unique permutations.
By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):
"123""132""213""231""3...
分类:
其他好文 时间:
2015-04-01 15:22:03
阅读次数:
150
第一个函数是计算熵的函数
function result=CEntropy(propertyList)
result=0;
totalLength=length(propertyList);
itemList=unique(propertyList);
pNum=length(itemList);
for i=1:pNum
itemLength=length(find(property...
分类:
其他好文 时间:
2015-04-01 09:39:24
阅读次数:
315
题目:
Given a string S,
find the longest palindromic substring in S.
You may assume that the maximum length of S is
1000, and there exists one unique longest palindromic substring.
思路:第一种思路,就是以某...
分类:
其他好文 时间:
2015-04-01 09:30:28
阅读次数:
115
第39例php生成不重复随机数<?phpheader("Content-type:text/html;charset=utf-8");$num=5;//要生产多少个随机数$start=0;$end=100;$connt=0;while($connt<$num){$a[]=rand($start,$end);//产生随机数$ary=array_unique($a);//遍历数组$a,如有相同的值则剔除该值$connt=c..
分类:
Web程序 时间:
2015-04-01 07:09:43
阅读次数:
174
poj——2031 最小生成树(MST) Kruskal算法Building a Space StationTime Limit:1000MSMemory Limit:30000KTotal Submissions:4985Accepted:2503DescriptionYou are a memb...
分类:
编程语言 时间:
2015-03-31 22:08:35
阅读次数:
186
原题链接:http://oj.leetcode.com/problems/unique-binary-search-trees/这道题要求可行的二叉查找树的数量,事实上二叉查找树能够随意取根,仅仅要满足中序遍历有序的要求就能够。从处理子问题的角度来看,选取一个结点为根,就把结点切成左右子树,以这个结...
分类:
其他好文 时间:
2015-03-31 21:39:33
阅读次数:
84
1 定义.proto接口文件package tutorial;message Person { required string name = 1; required int32 id = 2; //unique ID number for this person optional ...
分类:
其他好文 时间:
2015-03-31 17:40:49
阅读次数:
123
2都做了,把1补上。
题意给出n和k,还有n个数。就是n个数中 找出两个数x,y。使得 x+y=k。
计算所有的可能。当x0+y0=k。x1+y1=k 。 必须有不相等的。 x0!=x1 or y0!=y1。
例如
4 4
2 2 2 2
正确输出应该是 1 。
我是排序,去重,然后二分。貌似很多人都是用 two pointers。
忘了stl的二分返回下标的函数了,心情不...
分类:
其他好文 时间:
2015-03-30 23:11:41
阅读次数:
195
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-03-30 22:49:58
阅读次数:
162