How would you find the largest sum of a contiguous subarray?
Implement max_subarray_sum(nums) for a non-empty list of integers. Return the largest possible sum among all non-empty contiguous subarrays. The solution should run in linear time and use constant extra space.
nums is a non-empty list of integers. Return an integer containing the maximum contiguous-subarray sum.
def max_subarray_sum(nums):