Dsa
Sliding Window
Easy
Average of All K-length Subarrays
Given an array of integers and an integer K, compute the average of all contiguous subarrays of length K. You must read the input as a single line where the first integer is the length of the array followed by the elements of the array and finally K.
Example:
Input:
5 1 2 3 4 5
2
Output:
1.5 2.5 3.5 4.5
Key concepts
sliding_windowaveragesubarray
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