class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ import sys res, last = 0, sys.maxint len_prices = len(prices) for i in range(len_prices): profit, last = prices[i] - last if prices[i] > last else 0, prices[i] res += profit return res
|