Doubt on finding sum between indices i and j

At 6:00, we should check if i>=1 or not right?
If i=0 then cumSum[ i-1 ] = cumSum[ -1 ] = garbadge value right?

I think
currentSum = ( i==0 ) ? cumSum[ j ] : ( cumSum[ j ] - cumSum[ i-1 ])
should give correct answer?

hello @karan_bhut

yeah this one is correct.

in some compiler this may give garbage or segmentation fault .
so always prefer ->

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.