leetcode -- Best Time to Buy and Sell Stock II -- 重点注意思路
来源:互联网 发布:个股评测软件 编辑:程序博客网 时间:2024/06/02 05:06
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
因为可以进行无限次交易,并且在下一次buy之前必须已经sell。所以只需要把所有price曲线价格上涨的部分加起来就行。
参考
http://www.cnblogs.com/zuoyuan/p/3765980.html
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ maxprofit = 0 for i in range(1, len(prices)): if prices[i] >= prices[i-1]: maxprofit += prices[i] - prices[i-1] return maxprofit
0 0
- leetcode -- Best Time to Buy and Sell Stock II -- 重点注意思路
- leetcode -- Best Time to Buy and Sell Stock III --重点
- [LeetCode]Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock II
- Leetcode: Best Time to Buy and Sell Stock II
- [Leetcode] Best Time to Buy and Sell Stock II
- LeetCode : Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock II
- [LeetCode] Best Time to Buy and Sell Stock II
- leetcode 61: Best Time to Buy and Sell Stock II
- [LeetCode] Best time to buy and sell a stock II
- 【leetcode】Best Time to Buy and Sell Stock II
- LeetCode - Best Time to Buy and Sell Stock II
- LeetCode之Best Time to Buy and Sell Stock II
- [LeetCode]Best Time to Buy and Sell Stock II
- [Leetcode]Best Time to Buy and Sell Stock II
- [leetcode]Best Time to Buy and Sell Stock II
- [LeetCode] Best Time to Buy and Sell Stock II
- this指针的含义
- 10G(82599EB) 网卡测试优化(other)
- 杭电 1086 You can Solve a Geometry Problem too 判断线段是否相交.
- 堆栈、栈帧与函数调用过程分析
- 10G(82599EB) 网卡测试优化(中断处理)
- leetcode -- Best Time to Buy and Sell Stock II -- 重点注意思路
- java设计模式(五)—命令模式
- 10G(82599EB) 网卡测试优化(ethtool)
- Mac下,MySQL数据库中文乱码的解决方法
- Java线程2-1 线程池知识学习
- 10G(82599EB) 网卡测试优化(jumbo frame, tcp win scaling)
- Android异步任务处理之Thread线程
- 关于篮球--感
- ORACLE11g R2 DG FOR OEL7.1