"from typing import List
def maxprofitgreedy(stock_prices: List[int]) -> int:
l=0 # buying
r=1 # selling
max_profit=0
while rstock_prices[l]:
profit=stockprices[r]-stockprices[l]
maxprofit=max(maxprofit,profit)
else:
l=r
r+=1
return max_profit
debug your code below
print(maxprofitgreedy([7, 1, 5, 3, 6, 4]))
`"
Prajwal M. - "from typing import List
def maxprofitgreedy(stock_prices: List[int]) -> int:
l=0 # buying
r=1 # selling
max_profit=0
while rstock_prices[l]:
profit=stockprices[r]-stockprices[l]
maxprofit=max(maxprofit,profit)
else:
l=r
r+=1
return max_profit
debug your code below
print(maxprofitgreedy([7, 1, 5, 3, 6, 4]))
`"See full answer