Problem Description:
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 complete at most two transa...
分类:
其他好文 时间:
2014-06-05 09:33:52
阅读次数:
342
Say you have an array for which theithelement
is the price of a given stock on dayi.If you were only permitted to complete at
most one transaction (ie...
分类:
其他好文 时间:
2014-05-30 16:30:00
阅读次数:
282
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-30 16:19:05
阅读次数:
320
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-30 15:00:54
阅读次数:
335
class Solution {public: int maxProfit(vector
&prices) { if(prices.size() == 0) return 0; vector f(prices.size()); f[0] =
0; ...
分类:
其他好文 时间:
2014-05-30 02:46:12
阅读次数:
318
一次过,思路是:最大收益可以由所有上升序列差价叠加中获得 1 public class
Solution { 2 public int maxProfit(int[] prices) { 3 int profit = 0; 4 if
(prices.lengt...
分类:
其他好文 时间:
2014-05-29 20:43:33
阅读次数:
254
题目: 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 co...
分类:
其他好文 时间:
2014-05-28 22:37:18
阅读次数:
327
一个系列三道题,我都不会做,google之答案。过了两道,第三道看不懂,放置,稍后继续。一、Best
Time to Buy and Sell Stock
I题目:一个数组表示一支股票的价格变换。要求只买卖一次,获得最大收益。思路:一开始我认为是寻找最大、最小值,但由于最大值不一定总是出现在最小值的...
分类:
其他好文 时间:
2014-05-28 01:21:52
阅读次数:
262
题目: Say you have an array for which the ith element
is the price of a given stock on day i. If you were only permitted to complete
at most one transac...
分类:
其他好文 时间:
2014-05-28 00:55:20
阅读次数:
288
题目: 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 co...
分类:
其他好文 时间:
2014-05-28 00:53:26
阅读次数:
338