• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
May 11, 2022 |56.0K Views

Maximum of all subarrays of size 'k' using Sliding Window Technique

Description
Discussion

Given an array and an integer K, find the maximum for each and every contiguous subarray of size k.

Examples :

Input: arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}, K = 3 
Output: 3 3 4 5 5 5 6
Explanation: 
Maximum of 1, 2, 3 is 3
Maximum of 2, 3, 1 is 3
Maximum of 3, 1, 4 is 4
Maximum of 1, 4, 5 is 5
Maximum of 4, 5, 2 is 5 
Maximum of 5, 2, 3 is 5
Maximum of 2, 3, 6 is 6

Maximum of all subarrays of size 'k' using Sliding Window Technique:https://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/