Share my 3 lines Python solution


  • 5
    J
    class Solution(object):
        def maxSubArray(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            for i in xrange(1,len(nums)):
                    nums[i] = max(nums[i - 1] + nums[i], nums[i])
            return max(nums)

Log in to reply
 

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