This code will not work if the array given doesn't start with a 0?

The csum array has its 0th index as zero and we use it to find out the sum , but if my input array’s 0th index is not 0 this code will give wrong output, if we have an array that does not start with zero , as the current code will not include the input array’s 0th index . Is this so that we have to always have the 0th index of input array as 0 ? , we can change both the counters to print the max sum subarray .

is there a way to get correct sum with this logic when we dont have the 0th index of input array as 0 , I can only get it to print the correct array and not the correct sum

cant get this to work without the 0th index not being zero in any of the case

hi @garvit510bhatia make csum array of size n+1 and then keep zero index as 0 it will work then

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.