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
问题
费波那契数列(意大利语:Successione di Fibonacci),又译费波拿契数、斐波那契数列、斐波那契数列、黄金分割数列。
在数学上,费波那契数列是以递归的方法来定义:
F0 = 0 (n=0)
F1 = 1 (n=1)
Fn = F[n-1]+ F[n-2](n=>2)
关于Fibonacci的精彩解释,请看下列视频:
TED-神奇的斐波那契数列:http...
分类:
其他好文 时间:
2014-07-08 17:36:04
阅读次数:
237
def FirstNotRepeatingChar(string):
hashStr = [0] * 256
for c in string:
hashStr[ord(c)] += 1
for c in string:
if hashStr[ord(c)] == 1:
return c
这里说下ord, 可以作为atoi来用,功能是若给定的参数是一个长度为1的字符串,那么若...
分类:
其他好文 时间:
2014-07-08 16:15:10
阅读次数:
183
在博文:http://blog.csdn.net/qiwsir/article/details/31375449 中,讲述了如何用贪婪算法解决找硬币的问题,同时也指出了该方法存在的问题。
如何解决?
下面就是一个解决方案,在这里采用的是动态算法。
def coinChange(centsNeeded, coinValues):
minCoins = [[0 for j in ra...
分类:
其他好文 时间:
2014-07-08 15:27:17
阅读次数:
213
# @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
一块N x N(1
1:转90度:图案按顺时针转90度。
2:转180度:图案按顺时针转180度。
3:转270度:图案按顺时针转270度。
4:反射:图案在水平方向翻转(以中央铅垂线为中心形成原图案的镜像)。
5:组合:图案在水平方向翻转,然后再按照1到3之间的一种再次转换。
6:不改变:原图案不改变。
7:无效转换:无法用以上方法得到新图案。...
分类:
其他好文 时间:
2014-07-08 14:33:24
阅读次数:
161
题目
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant spac...
分类:
其他好文 时间:
2014-07-08 13:46:26
阅读次数:
205
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