From 0b25b3e379c31e89c21e7f74903829798830699b Mon Sep 17 00:00:00 2001 From: unknown <1326cy@gmail.com> Date: Mon, 31 Aug 2026 22:36:03 +0900 Subject: [PATCH] day33 --- .../121. Best Time to Buy and Sell Stock.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/121. Best Time to Buy and Sell Stock.py" 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