We all know about the maximum sum subarray and the famous Kadane's algorithm. But can we use the same algorithm to find minimum sum also?
My take is:
change the sign and find the max sum in that, same as the way we calculate the maximum sum subarray. Than change the sign of the elements in the array to make it in initial state.
Please help me in correcting the algo if it has any issue.
corner case: I know there is an issue if all the elements are positive and we can handle this case by doing some preprocessing i.e. traverse the array if all are +ve than just return the minimum number from the array.
The above mention algorithm will work and well supported (explained) by dasblinkenlight.