Implement a variation of Kadane’s algorithm to solve a specific array problem.
Given a non-empty list of integers, return the largest sum among all contiguous subarrays. The subarray must contain at least one element, and the result may be negative.
Function signature: def max_subarray_sum(nums):
Input is a list of integers. Output is one integer representing the maximum contiguous subarray sum.
def max_subarray_sum(nums):