Showing posts with label Maximum. Show all posts
Showing posts with label Maximum. Show all posts

Maximum of all subarrays of size k

Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.
Input :
arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}
k = 3
SubArray : [1,2,3] , [2,3,1], [3,1,4] .....
Output :
3 3 4 5 5 5 6