In this editorial to find maximum sum of a circular array. I could not get the correctness of -
Spoiler if you haven't solved the question yet
" in the case of circular fashion having maximum sum we can find it by just subtracting the minimum subarray sum from the cumulative sum".
What I understand after thinking through is if the minimum subarray is in between 0-n then the minimum subarray case for circular sum will correctly give the maximum circular sum, for example,
1 2 -3 -4 5, in this case, minimum subarray sum is 7 and is in between 0 - n index, which if removed can give the maximum circular sum.
and if the minimum subarray(it is not actual subarray, considering circular array ) is in between, say n-1 & 0 that case will be handled correctly by the candidate1 in the solution. for example
-3 1 2 5 -4 in this case candidate1(using Kadane’s algorithm) will give the maximum circular sum.
Am I correct in my explanation?
thanks.