Maximum sub arrays 2

while calculating the sum of sub arrays we initialize the value of i as 0 in the nested loop, then while calculating the cumsum of [i-1] why it is not showing a garbage value?

@SARTHAK
hello Sarthak,
it depends on compiler some compiler gives runtime error,some gives 0 or garbage value.

u should avoid accessing negative indices it is not good practice. In the given problem when i=0 then handle it separately by putting if statement inside ur loop.

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.