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