Inverted subarray

array-sum - (-max subarray sum of inverted array) why two negatives?

hey @sahazeer123 two negatives because, according to the theory we should subtract the min subarray sum from the total sum and the min subarray sum is represented by (-max_subarray_sum) on the inverted array.
So, we get first negative from theory and second from the representation of min subarray sum.

why min subarray sum = -max subarray sum of inverted array ? is there any proof

we multiplied each element with -1 and the found out the max sum subarray array since each element was multiplied with -1 it would make the min sum subarray in the real array. The intuition behind this is a rather common one. Bigger the magnitude of the number smaller its negation will be.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.