首页 > 代码库 > Leetcode Best Time to Buy and Sell Stock II

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



Leetcode Best Time to Buy and Sell Stock II