Given array of mtegers fmd the maximal possible sum of some of its k consecutive elements Example
for array - (2, 3, 5, i, 6]. k - 2 output should be 8
• [input] array.integer inputArray
o array of posrtive mtegers
• [input] integer k
o an integer (not greater than the length of inputArray )
• [output] integer
o the maximal possible sum
□
COOE
1* arrayflaxConse<utiveSu«( [J InputArray, k) { 2
3 * result - 0,
5
6» ( i - 0; i < k - 1; i++) {
7 currentSura ♦- inputArray[i];
9* ( i - k - 1; i < inputArray.length; i**) {
11 * i i (currentSua > result) {
12 result - currentSua;
14 currentSua -- inputArray[i - k ♦ 1];
15 }
16
17 Hrt result;
19