Maximum Subarray Sum

The code explained in the video starts loop of i from 0 and for finding the current sum through cummulative sum there it is a[j]-a[i-1], but for first iteration for i = 0 the sum would ask for a[-1]. How is that possible? Isn’t it wrong?

Hey @Sakshi2004
Yes u are correct
Sir missed it
you have to add condition for that
if(i==0)csum=a[j];
else csum=a[j]-a[i-1];

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us 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.