Maximum Sum
InterviewTime limit1sMemory limit128 MB
Given n integers and a window size k, find the largest sum of any k consecutive terms.
- Level
Easy3 of 10
- Topics
- Array, Sliding window, Prefix sum
- Solved
- No attempts yet
Problem
You are given a sequence of integers and a positive integer (). Write a program that outputs the maximum value of the sum of consecutive terms
Input
The first line contains a positive integer () and a positive integer () in this order, separated by a space. Each of the following lines holds one term of the sequence: line (for ) contains ().
Output
Print a single line containing only the maximum value of .