Skip to content

Commit 7c25530

Browse files
committed
Week 5
1 parent 8854d7e commit 7c25530

File tree

1 file changed

+12
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)