Max sum sub-array cumilative method

for(i= 0 ; i<n ; i++){
for(j=i; j<n; j++)
{
sum= cumsum[ j ]-cumsum[ i-1 ];

}

}

If for first iteration i=0
then i-1=-1
so for cumsum[ i-1 ] with i=0 should give error???

@abhayg1602 yes maybe give some garbage so you have to check that separately no issue

prateek sir has written this code and it is working

@abhayg1602 yes it may or may not give garbage in our compiler but in online coding comp it will always give run time error so you have to make sure i-1>=0

I have tested it on many ide its working but ideally it should not??

@abhayg1602 yes as i said it will give runtime error in cp competitions on submission

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.