Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

var findMaxAverage = function(nums, k) { let max = -Infinity; for (let i = 0, sum = 0; i < nums.length; i++) { sum += nums[i] - (nums[i - k] || 0); if (i >= k - 1) max = Math.max(max, sum); } return max / k; };

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.