Given an array find the sub-array with the largest sum.
A = [2, -1, 2, 3, 4, -5]
ans = 10
The intended sub-array is 2, -1, 2, 3, 4
We can observe that for an array to contribute to the largest sum, the net sum for that subarray must be positive.
We can use this to construct our algorithm.
1. Start from the first element.
2. Keep a sum so far variable to sum the elements as we encounter them.
3. If the sum so far becomes less than zero, reset it to zero. We don't want it to contribute to largest sum.
4. If sum so far becomes, greater than the max sum, store this as the max sum.