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.
## Complete the 'maximumSum' function below.## The function is expected to return a LONG_INTEGER.# The function accepts following parameters:# 1. LONG_INTEGER_ARRAY a# 2. LONG_INTEGER m#importtypingclassA(typing.NamedTuple):i:intv:intdefmaximumSum(a,m):psum=0x=[]fori,vinenumerate(a):psum=(psum+v)%mx.append(A(i,psum))x=sorted(x,key=lambdae:e.v)# print(x)mx=x[-1].vfor(i1,v1),(i2,v2)inzip(x[:-1],x[1:]):if(i1>i2):mx=max(mx,v1-v2+m)returnmx
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Subarray Sum
You are viewing a single comment's thread. Return to all comments →