Skip to content

Commit c3887f2

Browse files
Merge pull request #1946 from CodingTestStudy2/최민지
[최민지] Day33
2 parents 2a96f89 + e1bff7b commit c3887f2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎leetcode3/최민지/121.py‎

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

0 commit comments

Comments
 (0)