solution for the problem of maximum subarray