here if we take i=0 in loop the index of cs[i-1] will become -1.
how is that possible?
Doubt in code loop cannot have i=0
Hello @dhasmanasaksham572 Yes we have to add one constraint which Sir missed
if(i>=1)
current_sum = cum_sum[j] + cum_sum[i-1];
else
current_sum= cum_sum[j] ;
what is the need of csum[n]={0}
@dhasmanasaksham572 in this we are just making the initital sum at every point as 0.
it is just a good practice.
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.