121. Best Time to Buy and Sell Stock
unknown
python
2 years ago
305 B
8
Indexable
class Solution:
def maxProfit(self, prices: List[int]) -> int:
l, r = 0, 1
res = 0
while r < len(prices):
if prices[l] < prices[r]:
res = max(res, prices[r] - prices[l])
else:
l = r
r += 1
return resEditor is loading...