Dsa
Sliding Window
Medium
Max Sum of k Consecutive Days
You are given an array of integers representing daily sales. Find the maximum sum of sales you can get in any k consecutive days.
Input:
The first line contains two integers n and k (1 <= n <= 10^5, 1 <= k <= n).
The second line contains n integers, the sales values.
Output:
An integer representing the maximum sum over k consecutive days.
Example:
Input:
5 2
1 5 3 2 9
Output:
11
Key concepts
sliding_windowarraysummation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now