A chai stall writes down its profit for every day in the array nums. A loss is a negative number.
Pick one or more days that come one after another. Find the biggest total profit you can get from such a stretch of days, and return that total.
Examples
Example 1:
Input: nums = [-3,2,4,-1,3,-6,2]
Output: 8
Explanation: The 2nd to the 5th day give 2 + 4 - 1 + 3 = 8. No other stretch is better.
Example 2:
Input: nums = [-5]
Output: -5
Explanation: You must pick at least one day, so the answer is -5.
Example 3:
Input: nums = [4,-1,2,-10,6,3]
Output: 9
Explanation: The last two days give 6 + 3 = 9. The first three days give only 5.