Share my python solution

  • 1
    class Solution:
        # @param A, a list of integers
        # @return an integer
        def maxSubArray(self, A):
            l = A[:]
            for i in range(1, len(l)):
                l[i] = max(l[i], l[i]+l[i-1])
            return max(l)

  • 0

    This is typical example that solves DP in O(n) time from bottom up.

Log in to reply

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