• + 2 comments

    There's way more elegant solution on wikipedia:

    https://en.wikipedia.org/wiki/Maximum_subarray_problem