ASAPUtils Logo ASAPUtils
Week 2

Maximum Average Subarray I

Maximum Average Subarray I as the simplest possible fixed sliding window, with C++ and JavaScript solutions and the floating-point mistake that costs correct submissions.

The problem

Given an integer array and an integer k, find the contiguous subarray of length exactly k that has the maximum average, and return that average.

nums = [1, 12, -5, -6, 50, 3], k = 4 -> 12.75 (the subarray [12,-5,-6,50])

Related Problems