Solve problem by easy DP

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

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.