leaner algo to maximum-subarray problem