I think there is a problem in the code discussed in the CPP-Maximum Subarray Sum 2 video.
Because in the first case the code will try to evaluate the following:
currentsum=cumSum[0] - cumSum[-1] ;
but there no index as -1 so it will pick garbage value and the program will not give accurate output.
Problem in CPP-Maximum Subarray Sum 2
Hey @sahilkhan2312000131
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] ;