class Solution:
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
profits = 0
for day in range(len(prices)-1):
pro = prices[day+1] - prices[day]
if pro > 0:
profits += pro
return profits
leetcode - 122 - 买卖股票的最佳时机 II
最新推荐文章于 2024-03-02 10:12:33 发布