一、leetcode地址
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
二、问题描述
三、代码实现
语言:Python3
代码:
class Solution:
def maxProfit(self, prices: List[int]) -> int:
profit = 0
for i in range(len(prices)-1):
if prices[i+1] > prices[i]:
profit += prices[i+1]-prices[i]
return profit