Skip to content

Commit 872ccec

Browse files
author
sangbeenmoon
committed
could not solve maximun-subarray.
1 parent ba93191 commit 872ccec

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
ย (0)