Largest Subarray Sum
Largest Subarray Sum
Write max_subarray_sum(values: list[int]) -> int that returns the largest sum of any run of one or more adjacent elements in a single pass (Kadane's method): keep current, the best sum of a run that ends at the element you are on, and best, the largest current seen so far. For each value after the first, current becomes the previous current plus the value when that is larger than the value alone, otherwise the run starts afresh at the value; then best is updated when current beats it. The list has at least one value and the answer may be negative. This is O(n), against O(n squared) for the brute-force version. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of space-separated integers; the tests print the value your function returns.
Expected Output:
6= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...