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 570eaeb commit cdb6714Copy full SHA for cdb6714
best-time-to-buy-and-sell-stock/kayden.py
@@ -0,0 +1,15 @@
1
+# 시간복잡도: O(N)
2
+# 공간복잡도: O(1)
3
+class Solution:
4
+ def maxProfit(self, prices: List[int]) -> int:
5
+
6
+ answer = 0
7
+ cur = float(inf)
8
+ for price in prices:
9
+ if cur < price:
10
+ answer = max(answer, price - cur)
11
12
+ if price < cur:
13
+ cur = price
14
15
+ return answer
0 commit comments