Maximum Average Subarray I — Sliding Window

Given whole numbers and a block length, report the highest average any run of that many neighbouring values reaches.

Sliding Window · Easy

The problem

Given integers and a length k, find the run of k neighbours with the highest average, and give that average.

What to return

Constraints

Example

Input
nums = [1, 12, -5, -6, 50, 3], k = 4
Output
12.75

Solve it

More in Sliding Window

All algorithm problems