CodeBaobab
Practice studio
Loading Maximum Average Subarray

Maximum Average Subarray

Easy · Sliding Window · I. Fixed-Window Aggregates

Practice Maximum Average Subarray in the browser. Write your solution, run tests, and review the walkthrough after your attempt.

Find and return the maximum average of a contiguous subarray of exactly k elements in an integer array nums. Answers within 10^-5 of the exact value are accepted.

Constraints

  • 1 <= k <= nums.length <= 10^5
  • -10^4 <= nums[i] <= 10^4
  • answers within 10^-5 of the exact value are accepted

Builds on