Doubt in the loop where cumulative sum has been used

I had doubt that in the first for loop, i has been initialised from 0. So, when I will use this in
cumulative sum[j]-cumulative sum[i-1], i-1 will be negative so then there would be cumulative sum[-1]

hello @vageesha
yeah u r right .
to avoid this simply put one if statement and handle i=0 case seprately

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.