← All problems
#51 Max Subarray Sum Medium

Implement a program that computes the maximum sum of any contiguous subarray of length exactly window_size. You are given an array input of length N consisting of 32-bit signed integers, and an integer window_size.

Implementation Requirements

Example 1:

Input:  input = [1, 2, 4, 2, 3], window_size = 2
Output: output = 6

Example 2:

Input:  input = [-1, -4, -2, 1], window_size = 3
Output: output = -5

Constraints

Guided walkthrough coming soon. Below is the official starter signature in each language; the clickable line-by-line explanation hasn't been authored yet.
Problem text & starters from the official AlphaGPU/leetgpu-challenges. Solve it on leetgpu.com.