Sliding Window :
find a max sum of subarray of size k{3 here}.
Example :
1) arr[] : {3,2,4,5,2,1,1,1,1,3,3} , sum = 5, k = 2:
output : [4,5] = 9
class Sliding{
int findMax(int arr[], int k, int size){
int i = 0;
int j = 0;
int sum = 0;
int max = 0;
while(j < size){
sum = sum + arr[j];
if(j - i + 1 < k)
j++;
else if(j - i + 1 == k){
sum -= arr[i];
i++;
j++;
}
}
return sum;
}
}