这道题在前两个的基础上做稍微改进就可以。下面是AC代码: 1 /** 2 * Design an
algorithm to find the maximum profit. You may complete at most two transactions.
3 * @pa...
分类:
其他好文 时间:
2014-07-22 23:01:13
阅读次数:
251
需求是我们需要对服务器上的流量进行监控,网络上有个流传的check_traffic.sh,它需要被监控机开启snmp。但是感觉都使用上了nagios还要开snmp。。。有点斧子剪刀一起用的感觉,所以就动手写了个监控流量的shell:#!/bin/shusage()
{ echo "Usage: $0...
分类:
移动开发 时间:
2014-05-06 08:46:56
阅读次数:
361
Say you have an array for which theithelement
is the price of a given stock on dayi.Design an algorithm to find the maximum
profit. You may complete a...
分类:
其他好文 时间:
2014-05-06 00:51:29
阅读次数:
353
并查集类的c++封装,比较union_find algorithm四种实现方法之间的性能差别...
分类:
编程语言 时间:
2014-05-05 21:25:44
阅读次数:
324
HDU 2063
求一个二分图的最大匹配。
完全的裸题。贴代码。
#include
#include
#include
#include
#include
using namespace std;
vector G[1005];
bool check[1005];
int mac[1005];
int n;
void add_edge(int from,int to)
{
G[f...
分类:
其他好文 时间:
2014-05-02 20:57:04
阅读次数:
359
Write an efficient algorithm that searches for
a value in anmxnmatrix. This matrix has the following properties:Integers in
each row are sorted from l...
分类:
其他好文 时间:
2014-05-02 10:41:53
阅读次数:
267
The server network address “TCP://myserverAddress:50221″ cannot be reached or does not exist.
Check the network address name and that the ports for the local and remote endpoints are operational.
(Microsoft SQL Server, Error: 1418)...
分类:
Web程序 时间:
2014-05-01 18:35:53
阅读次数:
665
题目:
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.
翻译:
给定一个有序数组(递增),写程序构建一棵具有最小高度的二叉树。
思路:
要使二叉树的高度最小,则要尽量使其左右子树的节点数目相当,自然就考虑到将其构造成为二叉排序树,且将有序数组的中间大的数作为根节点,这样得到的二叉树的高度便是最小的。...
分类:
其他好文 时间:
2014-05-01 17:48:45
阅读次数:
321
在用到opencv中出现
opencv error :assertion faild (src.depth()==dst.depth()&&src.size==dst.size)找这个bug找了好久,网上有这样几种说法:
1.check这两个图或者矩阵是不是初始化了
2.如果初始化了,初始化的大小是不是一样,即两者有没有相同的长宽
3.两者的depth深度是不是一样,即是不是一个是三通道...
分类:
其他好文 时间:
2014-04-29 13:38:22
阅读次数:
647
又是一个新的算法,原来可以这样查找的。
我的一句话理解的思想:
计算可以抵消的数量,那么如果一个数出现的次数超过半那么最终这个数肯定不会被抵消完。
这个思想叫 Moore’s Voting Algorithm
有了这个思想武器之后,程序就可以写的很简单,可以很清楚看到怎么实现的,
参考资料可以看:...
分类:
其他好文 时间:
2014-04-29 13:22:22
阅读次数:
260