121. Best Time to Buy and Sell Stock
Caught me off guard - I was trying to use two pointers / typical l r sliding window but
1class Solution:
2 def maxProfit(self, prices: List[int]) -> int:
3
4 lowest = prices[0]
5 profit = 0
6
7 for price in prices:
8 lowest = min(lowest, price)
9 profit = max(profit, price - lowest)
10
11 return profit
#Neetcode150 #Sliding-Window #Python