What happens when value of i=0 and
Currentsum = cumsum[j] - cumsum[i-1] value of i-1 should be -1 so would it not give error
Maximum subarray sum 2
@ayushRsL
Hello Ayush,
If i==0 in that case your currentsum is just equal to cumsum[j].
so just add an if statement to handle that case.
currentsum[-1] will give you segementation fault(runtime error)
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.