121. Best Time to Buy and Sell Stock
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
class Solution:
def maxProfit(self, prices: List[int]) -> int:
minCost = float("inf")
maxProfit = 0
for price in prices:
maxProfit = max(maxProfit, price - minCost)
minCost = min(minCost,price)
return maxProfit
Last updated