Tap here to switch tabs
Problem
Submissions

Problem: Maximum Average Subarray I

Maximum Average Subarray I asks you to choose a contiguous subarray of a specified length from an integer array and return its largest average, including when values are negative.

Statement

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

Constraints:

  • 1≤1 \leqk ≤\leq nums.length ≤\leq 10510^5

  • −104≤-10^4 \leqnums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Average Subarray I

Maximum Average Subarray I asks you to choose a contiguous subarray of a specified length from an integer array and return its largest average, including when values are negative.

Statement

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

Constraints:

  • 1≤1 \leqk ≤\leq nums.length ≤\leq 10510^5

  • −104≤-10^4 \leqnums[i] ≤104\leq 10^4