122. Best Time to Buy and Sell Stock II
来源:互联网 发布:js contains方法 编辑:程序博客网 时间:2024/06/11 08:01
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
res=0
for i in range(1,len(prices)):
if prices[i]-prices[i-1]>0:
res+=prices[i]-prices[i-1]
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
res=0
for i in range(1,len(prices)):
if prices[i]-prices[i-1]>0:
res+=prices[i]-prices[i-1]
return res
距离一样,直接过去和跳着过去距离是一样的
阅读全文
0 0
- 122. Best Time to Buy and Sell Stock II
- LeetCode 122. Best Time to Buy and Sell Stock II
- 122.Best Time to Buy and Sell Stock II
- [Leetcode] 122. Best Time to Buy and Sell Stock II
- [leetcode] 122.Best Time to Buy and Sell Stock II
- 【leetcode】122.Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- 【LeetCode】122.Best Time to Buy and Sell Stock II
- [leetcode] 122. Best Time to Buy and Sell Stock II
- LeetCode #122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II LeetCode
- 122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- [LeetCode]122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- Leetcode 122. Best Time to Buy and Sell Stock II
- leetcode 122. Best Time to Buy and Sell Stock II
- grant授权语句
- 蓝牙状态
- 将博客搬至博客园http://www.cnblogs.com/daxianghaoshuai/
- pat1002.写出这个数(20)
- Linux-vi/vim常用命令手册
- 122. Best Time to Buy and Sell Stock II
- JNI 方法注册与签名
- Windows下如何使用curl命令?
- Android内存优化
- Maven 手动添加 JAR 包到本地仓库
- java JAI 实现多页TIF文件拆分保存成PNG格式
- PLSQL安装配置与错误解决
- C++中将图片序列写出到硬盘上?
- gcc升级