题目描述:

leetcode-714-买卖股票的最佳时机含手续费

方法一:

class Solution:
    def maxProfit(self, prices: List[int], fee: int) -> int:
        n = len(prices)
        dp_i_0 = 0
        dp_i_1 = float('-inf')
        for i in range(0,n):
            temp = dp_i_0
            dp_i_0 = max(dp_i_0,dp_i_1 + prices[i])
            dp_i_1 = max(dp_i_1,temp - prices[i] - fee)
        return dp_i_0

 

相关文章:

  • 2021-02-19
  • 2021-06-17
  • 2021-10-29
  • 2021-12-26
  • 2021-11-04
  • 2021-08-26
  • 2022-12-23
  • 2021-06-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-08-29
  • 2021-10-22
  • 2021-08-28
相关资源
相似解决方案