How Sir has done that?

How Sir has done that? Like You can see we want to find sum[i,j]=0 but sir is doing s[i+1,j]=0, I don’t understand the logic, Please help me for that.

@cbcao263
It depends on the implementation. for array[i:j] do you consider A[j] in the array or not. You need the numbers A[i],A[i+1],…,A[j].
The prefix sum array will be A[0] , A[0] + A[1] , A[0] + A[1] + A[2], … and so on.
Try to code it for a better picture and send me the code if you still do not get it.

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.