Why we write a-1 instead of a

sir has wrote csum[b]-csum[a-1] insted of writing csum[a].Why?

hi @swatantra1240_25a488bfc859a4ab,

for cummulative sum u need to write a-1 as u need sum from a to b eg array is 1,2,3,4,5 csum is 1,3,6,10,15 if u want sum from 2 to 4th index i.e 3+4+5 = 12 then u will do csum[4] - csum[2-1] => 15 - 3 = 12

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.