Skip to content

#643 - Maximum Average Subarray I

EasySliding Window
Open on LeetCode

Given an integer array nums of length n and an integer k, find a contiguous subarray of length k that has the maximum average value, and return that average. The answer will be accepted if the error is less than 10⁻⁵.

InputOutput
nums = [1,12,-5,-6,50,3], k = 412.75
nums = [5], k = 15.0
nums = [0,4,0,3,2], k = 14.0

Released under the MIT License.