best_time_buy_sell_stock_ii

2022-12-14 浏览 (801)

best_time_buy_sell_stock_ii.py 源码

from typing import List


# 买卖股票的最佳时机II

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

你可能感兴趣的文章

best_time_buy_sell_stock

climb_statirs

container_with_most_water

  • 所属分类: 后端技术
  • 本文标签: 技术
  • 版权声明: 本文链接 https://seaxiang.com/blog/1fc6765444664c3596d7acb0aa4abcfb