• + 0 comments
    def a(arr):
        r=min(0,max(arr))
        for e in arr:
            if e>0:
                r+=e
        return r
    def s(arr):
        l=[arr[0],arr[0]]
        for i in range(1,len(arr)):
            l[0]=max(arr[i],arr[i]+l[0])
            l[1]=max(l[1],l[0])
        return max(l)
        
    def maxSubarray(arr):
        return s(arr),a(arr)