摘要:
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol... 阅读全文
posted @ 2014-05-29 23:57
neverlandly
阅读(276)
评论(0)
推荐(0)
摘要:
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet... 阅读全文
posted @ 2014-05-29 04:03
neverlandly
阅读(270)
评论(0)
推荐(0)
摘要:
这道题求进行一次交易能得到的最大利润。如果用brute force的解法就是对每组交易都看一下利润,取其中最大的,总用有n*(n-1)/2个可能交易,所以复杂度是O(n^2)。跟Maximum Subarray非常类似,用“局部最优和全局最优解法”。思路是维护两个变量,一个是到目前为止最好的交易,另 阅读全文
posted @ 2014-05-29 03:37
neverlandly
阅读(395)
评论(0)
推荐(0)
浙公网安备 33010602011771号