HHP Inc·DSASDE-1Online Assessment
Maximum Sum Subarray of Size K
Problem
Find the maximum sum of any contiguous subarray of length k.
Example
[2,1,5,1,3,2], k=3 -> 9
Constraints
- 1 ≤ k ≤ n ≤ 10^5
Approach
Fixed-size sliding window. O(n).
added 6 days ago