when we find sum then why
sum=cumSum[j]-cumSum[i-1] at i=0
this does not fail here in your code array should go out of bound and use any garbage value?
Will it not fail sum=cumSum[j]-cumSum[i-1] at i=0?
yes there is slight bit of problem in the video, it will be rectified soon.