how in circular Sub-array sum the sum of non-contributing elements is equals to the sum of min sub-array sum(i.e. negative max sub-array sum of the inverted array)?
Circular Sub-array sum
Hey @kkunalguptaaa
Maximum value can have 2 cases
1)Either its from (i,j) where i<=j
or
2)Its from (0,i)+(j,n-1) where i>=0 and j<=n-1 and i<j
So 1st case is kadane & 2nd case
is maxprefix+max suffix == Total sum-min subarray
Sir my doubt was different i was asking that as mentioned in editorial that maxSubArraySum is equals to ArraySum-(sum of non-contributing elements), this logic is great but we implimented that arraySum-(minArraySum) and i don get this how maxArraySum + minArraySum is equals to ArraySum and minArraySum is equals to sum of non contributing elements.
This is not correct
Say
-100 10 20 -10 5
Here maxsubarraysum is 30 and minsubarraysum=-100
Totalsum== -75
As I told u above about 2nd case when maximum sum is formed from maximum prefix+macimum suffix such that i<j
So now assume we only say
prefix sum+suffix sum
=> total sum - sum from(i+1,j-1)
Now toa maximize above value we have to minimize value which is getting subtracted ==> minimum subarray of an array
And hence non contributing array in 2nd case is minimum subarray