implement linear-time maximum_subarray exercise