You are viewing a single comment's thread. Return to all comments →
So basically what he did in mathematical terms is
He differentiated the function, found the change in array keys like +100, -100 etc. :-
arr[lower-1]+=sum; if(upper < n) arr[upper]-=sum;
Then he integrated the derivated function to get the original function value at different points and found the max value:-
for(int i=0;i<n;i++){ temp += arr[i]; if(temp> max) max=temp; }
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
So basically what he did in mathematical terms is
He differentiated the function, found the change in array keys like +100, -100 etc. :-
Then he integrated the derivated function to get the original function value at different points and found the max value:-