Maximum subarray sum
Your task
After a long road trip you log one mood score per day, an integer that can be negative on rough days. You want to find the most enjoyable stretch of the trip: the consecutive block of one or more days whose scores add up to the largest total. Given the daily scores in order, return that maximum total. The list is non-empty. For example, [-2, 4, -1, 5] gives 8 for the stretch [4, -1, 5].
Examples
best_trip_stretch(mood: list[int]) -> intExample 1
Input
best_trip_stretch([-2, 4, -1, 5])Output
8Example 2
Input
best_trip_stretch([-3, -1, -2])Output
-1