📜  leetcode 122 best stock 2 - 任意代码示例

📅  最后修改于: 2022-03-11 15:00:05.933000             🧑  作者: Mango

代码示例1
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        size = len(prices)

        ans = 0
        for i in range(1, size):
            # This only calculates the accumulation profit in the case of existence of profits
            #            
            ans += max(0, prices[i]-prices[i-1])
        
        return ans
1234567891011