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 ba93191 commit 872ccecCopy full SHA for 872ccec
1 file changed
โmaximum-subarray/sangbeenmoon.pyโ
@@ -0,0 +1,12 @@
1
+# 30๋ถ ๋ด๋ก ํ์ง ๋ชปํจ.
2
+# prefix sum ์ ์ฌ์ฉํด์ ํ์ด๋ณด๋ ค๊ณ ํ์ผ๋ ์๊ฐ ์ด๊ณผ.
3
+# dp ๋ฌธ์ ์์ ํ์ ํ ์ ์๋ ์ง๊ด ํ์...
4
+
5
+class Solution:
6
+ def maxSubArray(self, nums: List[int]) -> int:
7
+ dp = [0] * len(nums)
8
+ dp[0] = nums[0]
9
+ for i in range(1, len(nums)):
10
+ dp[i] = max(nums[i], nums[i] + dp[i-1])
11
12
+ return max(dp)
0 commit comments