Code RoomMaximum subarray sum
EasyPrep Room Coding #679

Maximum subarray sum

CodingAlgorithms & data structuresEntry–Mid~10 min

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].

Implement
best_trip_stretch(mood: list[int]) → int
Examples
in[[-2,4,-1,5]]out8
in[[-3,-1,-2]]out-1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 10 min
InputExpectedGot
[[-2,4,-1,5]]8not run yetsample
[[-3,-1,-2]]-1not run yetsample