LeetCode 股票買賣系列問題

121 買賣一次 記錄遍歷到當前爲止的最小值,每次拿當前價格減去最小值,得到可能的收益,更新最大收益值,遍歷一次數組。 class Solution: def maxProfit(self, prices: List[int]) -> int: if not prices: return 0 minprice = float("Inf
相關文章
相關標籤/搜索