wrote code for maximum subarray, actually there are a couple of cases to watch out for