LeetCode 股票买卖系列问题

121 买卖一次 记录遍历到当前为止的最小值,每次拿当前价格减去最小值,得到可能的收益,更新最大收益值,遍历一次数组。 class Solution: def maxProfit(self, prices: List[int]) -> int: if not prices: return 0 minprice = float("Inf
相关文章
相关标签/搜索