Search for the maximum sum of a fixed-length subarray
Kotlin
Medium
loops
Task «Search for the maximum sum of a fixed-length subarray»
Write a program that takes an integer n, then n integers, and an integer k (1 ≤ k ≤ n). It is necessary to find the maximum sum of a subarray of length k. Print this sum.
Input Format
First line: integer n (1 ≤ n ≤ 10^5). Second line: n integers separated by spaces. Third line: integer k (1 ≤ k ≤ n).
Output Format
One integer — the maximum sum of a subarray of length k.
main.kt