ArrayIndexOutOfBonds error

Here in this maximum subarray sum 2 solution code, I think there is an issue in the code inside the two loops.
It is: currentSum = cumSum[j] - cumSum[i-1]
Actually here, when i value is 0, then it would be cumSum[-1] which is not defined and can give unpredictable results.

So, I just wanted to ask if I’m right with my doubt or there is something here that I’m missing. Also how should I fix it effectively.

Yes, you are right.

For that you have to share your code with me.
You can share this code using ide.codingblocks.com

  • A special url will be generated, share that url with me

Sure, I’ll code and share it with you soon.

Here’s the link: https://ide.codingblocks.com/s/584237

check now ->

Yes, I understood it. Thanks for the solving it.

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.