Skip to content

Commit bfef124

Browse files
authored
Update Best Time to Buy and Sell Stock - Leetcode 121.py
1 parent 3b61bc7 commit bfef124

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Best Time to Buy and Sell Stock - Leetcode 121/Best Time to Buy and Sell Stock - Leetcode 121.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ def maxProfit(self, prices: List[int]) -> int:
4444
for price in prices:
4545
profit = price - min_price
4646

47-
if price < min_price:
48-
min_price = price
49-
50-
if profit > max_profit:
51-
max_profit = profit
47+
min_price = min(price, min_price)
48+
max_profit = max(profit, max_profit)
5249

5350
return max_profit

0 commit comments

Comments
 (0)