You are viewing a single comment's thread. Return to all 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)
Seems like cookies are disabled on this browser, please enable them to open this website
The Maximum Subarray
You are viewing a single comment's thread. Return to all comments →