122. Best Time to Buy and Sell Stock II

class Solution(object):
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        profit=0
        for i in xrange(len(prices)-1):
            profit+=max(0,prices[i+1]-prices[i])
        return profit

你可能感兴趣的:(122. Best Time to Buy and Sell Stock II)