Intermediate~6 min · +40 XP
Sliding Window Maximum Sum
Practices: Sliding Window
Problem
Array: [2, 6, 1, 8, 4, 9, 3], window size k = 3.
The window slides one position at a time. What is the MAXIMUM sum of any window?
Examples
in: [1, 5, 2, 3], k = 2
out: 7
Windows: 6, 7, 5, max is 7 (window [5, 2]).
Constraints & conventions
- There are n − k + 1 = 5 windows.
Your answer
Solve the challenge to unlock the full approach and complexity analysis.