Python Solution


  • 0
    A
        def maxSubArray(self, nums):
            dp = {0:nums[0]}
            m = nums[0]
            for i in range(1,len(nums)):
                dp[i] = nums[i] + (0,dp[i-1])[dp[i-1] > 0]
                m = max(m,dp[i])
            return m
    

Log in to reply
 

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