🧠 Before you code — what pattern fits?
You are given an integer array nums of n elements and an integer k. Find a contiguous subarray of length exactly k that has the maximum average value, and return this value (answers within 10⁻⁵ are accepted).
([1,12,-5,-6,50,3], 4) → 12.75
🎬 Video explanation · Greg Hogg
Your solution runs against 3 unit tests, including edge and large-value cases.
Loading...
Test console · 3 unit tests
Submit your code to run it against all 3 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.