CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsSliding Window

Maximum Average Subarray I

Easy
LeetCode
1/6
EasySliding WindowLeetCode #643

Fixed window average

Sum first k, then slide: add right, remove left. Track max sum/k.

Examples

Example 1

Input

6 4
1 12 -5 -6 50 3

Output

12.75000
Example 2

Input

1 1
5

Output

5.00000

Stuck? Take a nudge

C++17Autosaves