Leetcode Best Time to Buy and Sell Stock II


class Solution:
    # @param {integer[]} prices
    # @return {integer}
    def maxProfit(self, prices):
        profit = 0;
        for i in xrange(1, len(prices)):
            if prices[i] > prices[i-1]:
                profit += prices[i] - prices[i-1]
        return profit



原文地址:https://www.cnblogs.com/gccbuaa/p/6845562.html