Maximum Subarray Sum
LuxoftN-iX
Given an array of integers and a number n, find the maximum sum of n consecutive elements in the array.
Example:
Input: arr = [1, 2, 5, 2, 8, 1, 5], n = 2
Output: 10
Explanation: 2 + 8 = 10
Examples:
Input 1:
{"arr":[1,2,5,2,8,1,5],"n":2}Output 1:
10Input 2:
{"arr":[1,2,5,2,8,1,5],"n":4}Output 2:
17Loading editor...
Run your code to see results
Click the Run button above