class Solution:
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
profit = 0
for i in range(1,len(prices)):
if prices[i]>prices[i-1]:
profit += prices[i] - prices[i-1]
return profit
122. 买卖股票的最佳时机 II
最新推荐文章于 2024-09-01 14:36:22 发布