Maximum Average Subarray I

1Easy

Maximum Average Subarray I

Given an integer array nums and integer k, find a contiguous subarray of length k with the maximum average value. Return the maximum average.

Example 1:

Input: nums = [1,12,-5,-6,50,3], k = 4 Output: 12.75 (subarray [12,-5,-6,50])

Example 2:

Input: nums = [5], k = 1 Output: 5.0

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕
Maximum Average Subarray I — Easy Arrays Algorithm | ClearCode