 All Problems
Maximum Average Subarray I
easy
arrays
sliding window
amazon
google

Given an integer array nums and integer k, find the contiguous subarray of length exactly k that has the maximum average. Return the maximum average (formatted to 5 decimal places).

Example 1:

Input: 1 12 -5 -6 50 3
k: 4
Output: 12.75000

Input format: Line 1: space-separated array. Line 2: k.

Output format: Maximum average, 5 decimal places.

Run to check your code against the sample cases, or submit to run every case