2025-06-03 20:23:08 -07:00

12 lines
256 B
Python

def maxProfit(self, prices: list[int]) -> int:
lowest = prices[0]
max_profit = 0
for x in prices[1:]:
if x - lowest > max_profit:
max_profit = x - lowest
if x < lowest:
lowest = x
return max_profit