Search⌘ K
AI Features

Solution: Maximum Average Subarray I

Understand how to apply the sliding window pattern to efficiently calculate the maximum average of any contiguous subarray of fixed length k. This lesson guides you through a linear time solution that updates sums dynamically to optimize performance and minimal space.

Statement

Given an array of integers nums, and an integer k, return the maximum average of a contiguous subarray of length k.

Constraints:

  • 11 \leqk \leq nums.length \leq ...