1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
class : def maxProfit(self, prices: List[int]) -> int: l = 0 res = 0; for i in range(1, len(prices)): profit = prices[i] - prices[l] if profit > res: res = profit if prices[i] < prices[l]: l = i return res
class : def maxProfit(self, prices: List[int]) -> int: res = 0 for i in range(len(prices)-1): res = max(res, max(prices[i+1:]) - prices[i]) return res
|
近期评论