You are viewing a single comment's thread. Return to all comments →
use bisect ........
def maximumSum(a, m): mm,pr=0,0 a1=[] for i in a: pr=(pr+i)%m mm=max(mm,pr) ind=bisect.bisect_left(a1,pr+1) if(ind<len(a1)): mm=max(mm,pr-a1[ind]+m) bisect.insort(a1,pr) return mm
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 →
use bisect ........