Back to Main
Learn Code
Depth-First Search
Greedy Algorithms
Get Premium
Sliding Window
Maximum Sum of Subarrays of Size K
easy
DESCRIPTION
Given an array of integers nums and an integer k, find the maximum sum of any contiguous subarray of size k.
Example 1: Input:
Output:
Explanation: The subarray with the maximum sum is [5, 1, 3] with a sum of 9.
Explanation
We maintain a fixed size window of size k throughout the array, and return the maximum sum of all those windows at the end.
Solution
start
max subarray sum of size k
0 / 16
Python
Login to track your progress
Your account is free and you can post anonymously if you choose.