Your question is Max Subarray Sum in Window. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An Apple Watch diagnostics pipeline stores sensor readings in chronological order. Given an integer array readings and a window size k, find the maximum sum among all contiguous windows containing exactly k readings.
Implement a function that accepts:
readings: a list of integers representing sensor readings.k: a positive integer window size.Return an integer containing the largest sum of any k consecutive elements. The window must contain exactly k readings, and its elements must be contiguous. Do not reorder readings.
def max_sensor_window_sum(readings, k):