Maximum sub array(video part)

in the video, while calculating precomputation part of cumulative sum, we started i from 1, bcuz we are using csum[i-1], so that it doesnt show segmentation fault, but while finding sum when i =0 initially, how we are able to use csum[i-1] , without error

this should show segmentation fault, actually all these things depend on machine and compiler

you should do it like this

for (int i = 0; i < n; i++) {
        if (i == 0)
            cumSum[i] = arr[i];
        else
            cumSum[i] = cumSum[i - 1] + arr[i];
    }

or you can do it like this

cumSum[0] = arr[0];
    for (int i = 1; i < n; i++) {
        cumSum[i] = cumSum[i - 1] + arr[i];
    }

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.