Question: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
Question Name: Best Time to Buy and Sell Stock II
1 2 3 4 5 6 7 8 9 10 | class Solution: # @param prices, a list of integer # @return an integer def maxProfit(self, prices): maxProfit = 0 for index in xrange(len(prices)-1): if prices[index+1] > prices[index]: # As long as we can earn money, do the transaction. maxProfit += prices[index+1] - prices[index] return maxProfit |