Problems with this line of code:
current_sum = cum_sum[j] + cum_sum[i-1];
for i = 0 it will cause problem as cum_sum[-1] will produce junk value
Problems with this line of code:
current_sum = cum_sum[j] + cum_sum[i-1];
for i = 0 it will cause problem as cum_sum[-1] will produce junk value
Hey for that replace this by
if(i>=1)
current_sum = cum_sum[j] + cum_sum[i-1];
else
current_sum= cum_sum[j] ;
current_sum = cum_sum[j] - cum_sum[i-1];
current_sum = cum_sum[j] - cum_sum[i-1];
I make the 1st element of cum_sum[0] = 0; It is working fine. Thanks
Yup u can do that as well