蚕蛹专题

小黑跟中老黑和阿黄吃了烤蚕蛹知了,喝了阿黄带来的茅台,耳机又莫名其妙第丢了逐渐减少内耗的leetcode之旅:714. 买卖股票的最佳时机含手续费

小黑代码(独立做出) class Solution:def maxProfit(self, prices: List[int], fee: int) -> int:# 数组长度n = len(prices)if n < 2:return 0# 动态规划变量buy = -prices[0]sell = 0for i in range(1, n):buy = max(buy, sell-prices