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 1dd83e6 commit b9abf48Copy full SHA for b9abf48
โbest-time-to-buy-and-sell-stock/hyogshin.pyโ
@@ -1,3 +1,14 @@
1
+'''
2
+๋ฌธ์ ํ์ด
3
+- ์ด์ค for ๋ฌธ์ผ๋ก ๊ตฌํ์ O(n^2) ์ผ๋ก ์๊ฐ ์ด๊ณผ
4
+- least_num์ ํ์ฌ ๋ ์ง ์ด์ ์ ๊ฐ์ฅ ์ธ๊ฒ ์ด ์ ์๋ ๊ธ์ก์ ์ ๋ฐ์ดํธ
5
+- dp๋ก ํด๋น ๋ ์ง๊น์ง ๊ฐ์ฅ ํฐ ์์ต์ ์ ์ฅ
6
+์๊ฐ ๋ณต์ก๋: O(n)
7
+- for ๋ฌธ ํ๋ -> O(n)
8
+๊ณต๊ฐ ๋ณต์ก๋: O(n)
9
+- dp ๋ฆฌ์คํธ -> O(n)
10
11
+
12
class Solution:
13
def maxProfit(self, prices: List[int]) -> int:
14
dp = [0] * (len(prices) + 1)
0 commit comments