

Input: 'arr' = [1, 4, -2] and 'k' = 2
Output: 5
Explanation: The subarray with the largest sum is [1, 4]. So the sum will be 5.
The first line contains two space-separated integers, ‘n’ and ‘k’.
The second line contains ‘n’ space-separated integers, representing the array ‘arr’ elements.
Print the largest sum of the subarray containing at least 'k' numbers.
You do not need to print anything. It has already been taken care of. Just implement the given function.
The basic idea is to check all the subarrays possible for the array. We find the sum of all subarrays having at least ‘k’ numbers and find the maximum sum from all of them.
The basic idea is to store the sum of the previous window to save space. We find the sum first window. For subsequent windows, we add the current element of the array and update the maximum sum. We then check whether the first element of the previous window is negative or not. If negative, we remove that element from the sum and again update the result.
The basic idea is to find the maximum sum for every index of the array. We then use the concept of the sliding window technique of size ‘k’. We first find the sum of the first ‘k’ elements of the array. For finding the sum of the next window, we first remove the first element of the previous window and add the current element. We now check whether the current sum is maximum or not. We also add the max sum of the last window in the current window to check if the sum is maximized or not.