Skip to content

Commit c24f0ea

Browse files
committed
Time: 23 ms (94.18%) | Memory: 28.5 MB (89.36%) - LeetSync
1 parent ae2d223 commit c24f0ea

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int]) -> int:
3+
min_price = float('inf')
4+
max_profit = 0
5+
6+
for price in prices:
7+
if price < min_price:
8+
min_price = price
9+
10+
elif price - min_price > max_profit:
11+
max_profit = price - min_price
12+
13+
return max_profit

0 commit comments

Comments
 (0)