i am not able to understand the question and also the approach rather than simple max subarray sum using kadane algorithm but i unloacked editorial still not able to understand editorial any other solution or approach
Not able to understand this question and also editorial
There can be two cases for the maximum sum:
Case 1: The elements that contribute to the maximum sum are arranged such that no wrapping is there. Examples: {-10, 2, -1, 5}, {-2, 4, -1, 4, -1}. In this case, use Kadane’s algorithm to get result.
Case 2: The elements which contribute to the maximum sum are arranged such that wrapping is there. Examples: {10, -12, 11}, {12, -5, 4, -8, 11}. In this case,find out the sum of non contributing elements and subtract this sum from the total sum. To find out the sum of non contributing, invert sign of each element and then run Kadane’s algorithm.
Finally we compare the sum obtained by both cases, and return the maximum of the two sums.