class Solution:
def maxProfit(self, prices: List[int]) -> int:
res = 0
for i in range(len(prices)):
if i == 0:
continue
else:
if prices[i]-prices[i-1] > 0:
res += prices[i]-prices[i-1]
return res
122. 买卖股票的最佳时机 II
最新推荐文章于 2024-08-15 01:55:01 发布