Maximum of all subarrays of size k
Hard

Problem Statement

Given an array of integers and a number k, find the maximum for each and every contiguous subarray of size k.

Examples

1Example 1
Input:
{ "arr": [ 1, 3, -1, -3, 5, 3, 6, 7 ], "k": 3 }
Output:
[ 3, 3, 5, 5, 6, 7 ]
2Example 2
Input:
{ "arr": [ 8, 5, 10, 7, 9, 4, 15, 12, 90, 13 ], "k": 4 }
Output:
[ 10, 10, 10, 15, 15, 90, 90 ]
3Example 3
Input:
{ "arr": [ 1, 2, 3, 4, 5 ], "k": 1 }
Output:
[ 1, 2, 3, 4, 5 ]
Loading...

Sign in to Run Code and Submit