Question bank › Sliding Window
Dsa Sliding Window Medium

Average of Consecutive Elements

Given an array of integers and an integer k, compute the average of each contiguous subarray of size k. Return the averages as a list of floats, rounded to two decimal places. Input Format: - The first line includes the integer k (window size). - The second line is an array of integers (space-separated). Output Format: - A list of floats representing the averages of the contiguous subarrays of size k. Example: Input: 3 1 2 3 4 5 Output: [2.00, 3.00, 4.00]

Key concepts

sliding_windowaveragearray

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.