Find number which appears more than half times
of array length.
分类:
移动开发 时间:
2014-05-27 00:16:48
阅读次数:
339
Given an array of integers, every element appears
three times except for one. Find that single one. Note: Your algorithm should
have a linear runtime ...
分类:
其他好文 时间:
2014-05-27 00:10:26
阅读次数:
319
Check nagios配置文件报错例如以下:[nagios@2 etc]$
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgNagios Core
4.0.6Copyright (c) 2009-present Nag...
分类:
移动开发 时间:
2014-05-27 00:07:04
阅读次数:
364
题目:
Problem Description
In the year 8888, the Earth is ruled by the PPF Empire . As the population growing , PPF needs to find more land for the newborns . Finally , PPF decides to att...
分类:
其他好文 时间:
2014-05-23 02:32:42
阅读次数:
298
克鲁斯卡尔
struct edge
{
int u, v, w;
}e[maxn];
int f[110];
bool cmp(edge a, edge b)
{
return a.w < b.w;
}
int find(int x)
{
if(x != f[x])
return f[x] = find(f[x]);
return f[x];
}
int MST()
{
int...
分类:
其他好文 时间:
2014-05-23 02:15:51
阅读次数:
267
Problem 1: Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multip...
分类:
其他好文 时间:
2014-05-23 01:43:01
阅读次数:
253
同样是查找一个图是否有环的算法,但是这个算法很牛逼,构造树的时候可以达到O(lgn)时间效率。n代表顶点数
原因是根据需要缩减了树的高度,也叫压缩路径(Path compression),名字很高深,不过其实不难理解,简单来说就是每次查找一个节点的时候,都把这一路径中的所有节点都赋予根节点作为路径。
原文没指出的地方:
也因为需要压缩,所以初始化的时候注意,不能如前面简单实用Unio...
分类:
其他好文 时间:
2014-05-23 00:21:42
阅读次数:
305
Problem 4: Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest pal...
分类:
其他好文 时间:
2014-05-22 18:48:46
阅读次数:
355
Given an array of integers, every element
appearstwiceexcept for one. Find that single one.Note:Your algorithm should have
a linear runtime complexity...
分类:
其他好文 时间:
2014-05-22 16:31:03
阅读次数:
194
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 le...
分类:
其他好文 时间:
2014-05-22 16:05:56
阅读次数:
239