Implement a solution for Kadane’s algorithm or sub-contiguous array problems.
Given a non-empty list of integers, return the maximum sum of any contiguous subarray and the inclusive start and end indices of one such subarray. If multiple subarrays have the same maximum sum, return any one of them.
Function contract: max_subarray(nums) accepts nums as a list of integers and returns [maximum_sum, start_index, end_index].
def max_subarray(nums):