Write max_subarray(nums) that returns the largest sum of any contiguous part of a non-empty list. [-2,1,-3,4,-1,2,1,-5,4] → 6.
max_subarray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) → 6
max_subarray([-3, -1, -2]) → -1
Submit runs 5 tests, including hidden edge cases.
Run your code to see the output here.