leetcode-122-买卖股票的最佳时机②

 

 题目描述:

方法一:

class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        profit = 0
        for i in range(1,len(prices)):
            tem = prices[i] - prices[i-1]
            if tem>0:
                profit += tem
        return profit

 

posted @ 2019-07-15 14:18  oldby  阅读(149)  评论(0编辑  收藏  举报