inside the j for loop . we have assigned currentsum = cumsum[j]-cumsum[i-1] but i=0 for starting iteration and accessing cumsum[-1] would give error
It sholud give out of bound error
yes that should not be done
accessing -1 index is a wrong practice
but like in some cases it works
but try to update it by checking if i-1 >=0 only then perform that stmt else skip that
1 Like