Code error index bound

In line 41 when i=0 and j=i;

the equation will become:-

sum = cSum[j] -cSum[i-1];

sum = cSum[0] - cSum[0-1];

So this cSum[0-1] will create -1 index which is giving error in leetcode question i was attempting.

hi @pks280721_627ff2dfc64a9898 yes u’ll get error as index is out of bound check if index is negative then subtract 0 else subtract csum[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.