Skip to content

Commit 7cb90cc

Browse files
committed
week5 - 1
1 parent e33db1c commit 7cb90cc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int]) -> int:
3+
min_price = prices[0]
4+
max_profit = 0
5+
for i in range(0, len(prices) - 1):
6+
min_price = min(prices[i], min_price)
7+
profit = prices[i+1] - min_price
8+
max_profit = max(profit, max_profit)
9+
return max_profit

0 commit comments

Comments
 (0)