Maximum subarray sum 2


in this code when we start from i=0 then what is the value of cumSum[-1]?

@nirupama1 Yes you should prevent negative indexes in the array as it may have some unexpected results depending on the compiler. But here it is not causing any error and taking the value at that index as 0. It basically depends on the compiler. So cumSum[-1]=0 here.

But our solution should be for all type of compilers …then the method explained here is not correct…i mean what if it took a value other than zero.

If you separately initialize cumSum[-1]=0…it will work in all compilers…otherwise the logic is correct…