for eg, if my input is 6,5,4,3,2,1,1 then maximum sum shown is 21 instead of 22
Doesn't work for all positive numbers
@samikshamodi7 hey Samiksha, In the video there is small mistake at index i = 0
we are accessing the negative index of array in this line : cs=cumsum[j]-cumsum[i-1];
so write below code :
if(i == 0)
cs = cumsum[j];
else
cs=cumsum[j]-cumsum[i-1];
@samikshamodi7 I hope I’ve cleared your doubt. Please mark this doubt as resolved and rate me on the basis of your experience. Rating option is just below where you mark this doubt as resolve. Your feedback is very important. It helps us to improve our platform and hence provide you the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.