Suppose we change the definition of the maximum-subarray problem to allow the result to be an empty subarray, where the sum of the values of an empty subarray is 0. How would you change any of the algorithms that do not allow empty subarrays to permit an empty subarray to be the result?

We would want to return an empty subarray only if the sum of the maximum subarray is negative. So, we can modify the algorithms to check if the sum it is going to return is negative, we will return the empty subarray instead.

A better aproach has been suggested by Kumar Ashis in the comment section, where we can initialize left-sum and right-sum to 0 instead of -∞ as we are not going to accept any negative sum as the answer.

If you have any question or suggestion or you have found any error in this solution, please leave a comment below.