We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 845cdbd commit d02e5ddCopy full SHA for d02e5dd
best-time-to-buy-and-sell-stock/HodaeSsi.py
@@ -0,0 +1,13 @@
1
+# 시간 복잡도 : O(n)
2
+# 공간 복잡도 : O(1)
3
+class Solution:
4
+ def maxProfit(self, prices: List[int]) -> int:
5
+ min_price = float('inf')
6
+ max_profit = 0
7
+
8
+ for price in prices:
9
+ min_price = min(min_price, price)
10
+ max_profit = max(max_profit, price - min_price)
11
12
+ return max_profit
13
0 commit comments