what exactly is suffix sum and how is it being calculated? According to me it should be 5 as well, but in the video it was said to be 3, please clarify.
What is suffix sum
@Ishitagambhir ,suffix of an array is the subbarray ending at the last index so suffix sum is the sum of subbarray ending at last index and In the context of this problem max suffix sum for the segment (i,j) is the maximum subarray sum ending at j.
In given eg we have the segment : 1 3 -4 5 -2
we can’t have 5 as max suffix sum as there is no subarray ending at index 4 with sum 5
If we were to write a program to find the max suffix sum for the segment i to j then it would be something like
max_suff_sum=arr[j];
sum=arr[j];
for(int index=j+1;index>=i;index--){
sum+=arr[index];
max_suff_sum=max(max_suff_sum,sum);
}