diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/121. Best Time to Buy and Sell Stock.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/121. Best Time to Buy and Sell Stock.py" new file mode 100644 index 00000000..8e92a585 --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/121. Best Time to Buy and Sell Stock.py" @@ -0,0 +1,13 @@ +class Solution: + def maxProfit(self, prices: List[int]) -> int: + ans = 0 + small = prices[0] + + for i in range(len(prices)): + profit = prices[i] - small + ans = max(ans, profit) + small = min(small, prices[i]) + + return ans + + \ No newline at end of file