Maximum Sum Window
Preview mode. Log in to edit, run, submit, and save progress.
Easy
Maximum Sum Window
Given an integer array nums and an integer k, return the maximum sum of any contiguous subarray of length k.
Examples
Example 1
Input:
nums = [1, 2, 3, 4, 5], k = 3
Output:
12
Explanation: The subarray [3, 4, 5] has the maximum sum.
Approach hint
Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
Loading...
Input
nums = [1, 2, 3, 4, 5], k = 3Output
12