Problem :

https://leetcode.com/problems/maximum-subarray/description/


My Solution :

class Solution:
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dp = nums[:]
for i in range(1, len(nums)):
if dp[i-1] > 0:
dp[i] += dp[i-1]
return max(dp)


Comment :

전형적인 동적 프로그래밍 문제