At i = 0 , how will the current sum be calculated?

In #35
currentSum = cumSum[j] - cumSum[i-1];
what will happen at i = 0? because it will be cumsum[-1] then …

@nipunbinjola yeah you’re right in this case array will try to access a negative index which may contain a garbage value there is a problem in this code you can refer to this line of code maximum subarray sum

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.

1 Like