leetcode 309. Best Time to Buy and Sell Stock with Cooldown
来源:互联网 发布:pla算法 迭代次数 编辑:程序博客网 时间:2024/06/05 22:56
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ """ https://discuss.leetcode.com/topic/30421/share-my-thinking-process/18 """ if len(prices) < 2: return 0 sell,buy,pre_sell,pre_buy = 0,-prices[0],0,0 for price in prices: pre_buy = buy buy = max(pre_sell-price,pre_buy) pre_sell = sell sell = max(pre_buy+price,pre_sell) return sell
阅读全文
0 0
- leetcode Best Time to Buy and Sell Stock with Cooldown
- LeetCode Best Time to Buy and Sell Stock with Cooldown
- Leetcode: Best Time to Buy and Sell Stock with Cooldown
- [LeetCode]Best Time to Buy and Sell Stock with Cooldown
- Leetcode Best Time to Buy and Sell Stock with Cooldown
- leetcode - Best Time to Buy and Sell Stock with Cooldown
- LeetCode:Best Time to Buy and Sell Stock with Cooldown
- leetcode Best Time to Buy and Sell Stock with Cooldown
- Leetcode Best Time to Buy and Sell Stock with Cooldown
- LeetCode:Best Time to Buy and Sell Stock with Cooldown
- LeetCode--Best Time to Buy and Sell Stock with Cooldown
- 309.Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- 309. Best Time to Buy and Sell Stock with Cooldown
- angular-bootstrap-nav-tree 插件的应用 abntree
- 欢迎使用CSDN-markdown编辑器
- 树状数组求不带修改前缀最值问题 51NOD 1272 最大距离
- mongo ping函数实例
- 标签控件Tab
- leetcode 309. Best Time to Buy and Sell Stock with Cooldown
- 翻译连载 | JavaScript轻量级函数式编程-第5章:减少副作用 |《你不知道的JS》姊妹篇
- 利用nginx 反向代理解决跨域问题
- LeetCode: 66. Plus One
- 翻译连载 | JavaScript轻量级函数式编程-第4章:组合函数 |《你不知道的JS》姊妹篇
- NGUI_的Atlas图集学习_005
- 树——重建二叉树
- 文件所有者、用户组和其他人的概念理解以及修改权限的操作
- 集群上配置Keepalived实现负载均衡