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 0b89fcc commit e9f8a75Copy full SHA for e9f8a75
best-time-to-buy-and-sell-stock/sejineer.py
@@ -0,0 +1,15 @@
1
+"""
2
+시간 복잡도: O(N)
3
+공간 복잡도: O(1)
4
5
+class Solution:
6
+ def maxProfit(self, prices: List[int]) -> int:
7
+ buy = prices[0]
8
+ result = 0
9
+
10
+ for price in prices:
11
+ profit = price - buy
12
+ buy = min(buy, price)
13
+ result = max(profit, result)
14
15
+ return result
0 commit comments