Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…
The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had to travel by tra...
分类:
其他好文 时间:
2015-02-03 09:37:13
阅读次数:
222
标题:Best Time to Buy and Sell Stock II通过率:37.3%难度:中等Say you have an array for which theithelement is the price of a given stock on dayi.Design an algor...
分类:
其他好文 时间:
2015-02-02 12:28:59
阅读次数:
124
标题:Best Time to Buy and Sell Stock通过率:32%难度:中等Say you have an array for which theithelement is the price of a given stock on dayi.If you were only per...
分类:
其他好文 时间:
2015-02-02 12:18:58
阅读次数:
138
题目: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 complet...
分类:
编程语言 时间:
2015-02-01 10:46:16
阅读次数:
251
思路: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 ...
分类:
编程语言 时间:
2015-01-31 21:47:24
阅读次数:
180
原题地址Best Time to Buy and Sell Stock III(参见这篇文章)的简化版迭代法求最大利润。当然是在峰值卖出,在低谷买进利润最大了。所以从后向前遍历所有价格,如果当前价格比之前的峰值价格还高,更新峰值价格,否则就用峰值价格减去当前价格看看利润多少。代码: 1 int ma...
分类:
其他好文 时间:
2015-01-30 17:22:44
阅读次数:
125
原题地址如果不限交易次数,把所有递增序列差值求和即可。代码: 1 int maxProfit(vector &prices) { 2 if (prices.empty()) 3 return 0; 4 5 int profi...
分类:
其他好文 时间:
2015-01-30 16:54:46
阅读次数:
129
Say you have an array for which the ith element isthe price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as manytransactions as you like (ie, buy one an...
分类:
其他好文 时间:
2015-01-30 09:11:13
阅读次数:
176
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 transactions.
注意
You may n...
分类:
其他好文 时间:
2015-01-28 14:47:27
阅读次数:
197
Stock PricesTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 987Accepted Submission(s): 397Problem...
分类:
编程语言 时间:
2015-01-28 00:50:14
阅读次数:
217