We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defmaxSubarray(arr):# Write your code heremaxx=0x=summ=arr[0]ifarr[0]>0else0h=arr[0]foriinrange(1,len(arr)):h=max(h,arr[i])summ+=arr[i]ifarr[i]>0else0x=arr[i]ifx<0elsex+arr[i]maxx=max(maxx,x)return[maxx,summ]ifmaxx!=0else[h,h]
Cookie support is required to access HackerRank
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 →