leetcode - 122 - 买卖股票的最佳时机 II

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
        

猜你喜欢

转载自blog.csdn.net/hustwayne/article/details/84930574