Skip to content

Commit 364183b

Browse files
committed
ADD : #221 by heypaprika
1 parent 3762dae commit 364183b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Big-O 예측
2+
# Time : O(n)
3+
# Space : O(1)
4+
class Solution:
5+
def maxProfit(self, prices: List[int]) -> int:
6+
min_price = prices[0]
7+
profit = 0
8+
9+
for price in prices[1:]:
10+
if min_price > price:
11+
min_price = price
12+
13+
profit = max(profit, price - min_price)
14+
return profit
15+

0 commit comments

Comments
 (0)