Spotify analyzes contiguous windows of playlist metrics, such as track engagement scores. Given an integer array nums and a window size k, return the maximum sum among all contiguous subarrays containing exactly k elements.
Implement max_subarray_sum(nums, k).
nums, a non-empty list of integers, and k, an integer window size.k.k elements.Use a fixed-size sliding window rather than recomputing every window from scratch.
def max_subarray_sum(nums, k):