instead of subarray the total array is getting printed
Maximum sub array sum
You just need to remove the last for loop which prints the array.
Hey! In line 23 of your code, when i==0, cursum[-1] is accessed which can give huge garbage value which can give the whole array as the answer so to avoid it we’ll add a condition:
if(i==0) cursum = cumsum[j];
else cursum=cumsum[j]-cumsum[i-1];
I have also added this change in your code, hope it makes sense to you! Kindly resolve this question and also rate if you liked my response,