You are provided with a function that is supposed to find the maximum sum of a contiguous subarray in a given list of integers. However, the function is broken and needs debugging. After fixing it, extend the functionality to also return the starting and ending indices of that subarray.
nums where -10^4 <= nums[i] <= 10^4.Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: (6, (3, 6))
Explanation: The contiguous subarray [4,-1,2,1] has the maximum sum of 6.
Example 2:
Input: nums = [1]
Output: (1, (0, 0))
Explanation: The only element is the maximum subarray.
1 <= nums.length <= 10^5.