LeetCode122 买卖股票的最佳时机 II
贪心计算爬峰收益
class Solution:
def maxProfit(self, prices: List[int]) -> int:
ans, l = 0, len(prices)
for i in range(1, l): ans += max(0, prices[i] - prices[i - 1])
return ans
标签:int,II,LeetCode122,ans,prices,贪心
来源: https://www.cnblogs.com/solvit/p/16423004.html