Max Array Sum

  • + 0 comments

    Using an additional array

    def maxSubsetSum(arr):
        L = [0] * (len(arr) + 1)
        L[1] = arr[0]
        
        for i in range(2, len(L)):
            L[i] = max(L[i-1], arr[i-1], arr[i-1]+L[i-2])
        return max(L)