Given an array and a number k, find the sum of the subarray that has the maximum sum among all the subarrays of size k.
Array: [3, 5, 6, 2, 4, 7, 8]
k: 3
Here, the subarrays of size k and their sum are:
[3 5 6] => 14
[5 6 2] => 13
[6 2 4] => 12
[2 4 7] => 13
[4 7 8] => 19
Answer: 19
The first line contains an integer âTâ denoting the number of test cases.
For each test case, the input contains two lines:
For each test-cases, the output has a single integer denoting the maximum subarray sum.
2
7 3
3 5 6 2 4 7 8
6 1
1 3 3 3 4 4
19
4
1 <= T <= 100
1 <= n <= 104
1 <= k <= n
1 <= Ai <= 104