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-07-09 23:32:44
阅读次数:
276
1. [文件] webtoolkit.sha1.js ~ 4KB /**** Secure Hash Algorithm (SHA1)* http://www.huiyi8.com/css3/***/function SHA1 (msg) {function rotate_left(n,s) {v....
分类:
编程语言 时间:
2014-07-09 00:46:00
阅读次数:
343
1. [文件] webtoolkit.md5.js ~ 7KB /**** MD5 (Message-Digest Algorithm)* http://www.huiyi8.com/webyuanma/?***/var MD5 = function (string) {function Rota....
分类:
编程语言 时间:
2014-07-09 00:45:24
阅读次数:
298
# @left part: [start, mid]
# @right part: (mid, end]
def merge(data, start, mid, end):
if mid < start or end < mid:
return 0
reverse = 0
'''
@ for start, it play as the start index of left par...
分类:
其他好文 时间:
2014-07-08 15:04:06
阅读次数:
204
Implement an algorithm to find the kth to last element of a singly linked list.Classical "Runner" Technique of linkedlist/*Use two pointers, forward o...
分类:
其他好文 时间:
2014-07-08 00:37:17
阅读次数:
315
与折半查找是同一个模式,不同的是,在这里不在查找某个确定的值,而是查找确定值所在的上下边界。
def getBounder(data, k, start, end, low_bound = False):
if end < start : return -1
while start > 1
if data[ mid ] ...
分类:
其他好文 时间:
2014-07-06 12:18:00
阅读次数:
311
The Game
Description
One morning, you wake up and think: "I am such a good programmer. Why not make some money?'' So you decide to write a computer game.
The game takes place on a rectangular...
分类:
其他好文 时间:
2014-07-06 09:02:34
阅读次数:
287
好久没写codility的题了,一来没时间,二来有的题目不太好分析。这个题比较有意思,我还没有给出非常严格的证明。给定一棵树(无向无环图),从一个节点出发,每次选择一个节点,从起点到目的节点的路径上没经过的节点尽可能多,直到遍历完所有的节点。如果起点到两个目的节点的路径中没经过的节点同样多,则选择标号较小的节点作为目的节点。如此继续,直到遍历所有的节点,求按顺序选择了哪些目的节点?例如从2 开始,...
分类:
其他好文 时间:
2014-07-06 08:43:57
阅读次数:
149
这个题比较简单,好像也比较old,给定一个整数数组A,有N个元素,找到所有下标对(P,Q)满足 0 ≤ P ≤ Q 数据范围N [1..3*10^5]数组元素[-10^9, +10^9]要求时间复杂度O(N),空间复杂度O(N)。分析: 如果b[i] = max{a[i..N - 1]} ,则对每个i,我们找到最大的j,满足b[j]>=a[i],就可以了。这样做的目的是b,反映了后面还有没有比a...
分类:
其他好文 时间:
2014-07-06 08:30:20
阅读次数:
179
也是比较有意思的题,越来越数学了……不善于做这种题。...
分类:
其他好文 时间:
2014-07-06 00:04:07
阅读次数:
289