【LeetCode】122. Best Time to Buy and Sell Stock II

版权声明:本文为博主原创文章,请尊重原创,转载请注明原文地址和作者信息! https://blog.csdn.net/zzc15806/article/details/81301523

class Solution:
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        max_pro = 0
        for i in range(1, len(prices)):
            if prices[i] > prices[i-1]:
                max_pro += prices[i] - prices[i-1]
        return max_pro

猜你喜欢

转载自blog.csdn.net/zzc15806/article/details/81301523