Problem title
Difficulty
Avg time to solve

Grid Overlap
Easy
20 mins
Immediate Smaller Element
Easy
15 mins
Minimum Distance Between Two Numbers
Easy
15 mins
Number of Ways
Moderate
35 mins
Longest Increasing Subsequence
Moderate
--
Choose Students
Moderate
25 mins
Equation Solver
Easy
10 mins
Predict the Winner
Moderate
25 mins
Longest Balanced Substring
Moderate
25 mins
Pairwise Sum of Hamming Distance
Moderate
30 mins 1

# Maximum in Subarrays of length K

Difficulty: EASY
Avg. time to solve
27 min

Problem Statement

#### Input Format:

``````The first line contains two single space separated integers, N and K.

The second line contains N single space separated integers denoting the elements of the array.
``````

#### Output format:

``````A single line consisting of N - K + 1 single space separated integers denoting the maximum values of the K-sized subarrays where the subarrays are taken in a left to right fashion starting from the 0th index.
``````

#### Constraints:

``````0 <= N <= 5 * (10 ^ 5)
1 <= K <= N

Time Limit: 1 sec
``````
##### Sample Input 1:
``````6 3
10 5 2 7 8 7
``````
##### Sample Output 1:
``````10 7 8 8
``````
##### Explanation for Sample Input 1:
``````We get the values 10 7 8 8 because:
10 = max(10, 5, 2)
7 = max(5, 2, 7)
8 = max(2, 7, 8)
8 = max(7, 8, 7)
``````
##### Sample Input 2:
``````7 3
12 1 78 90 57 89 56
``````
##### Sample Output 2:
``````78 90 90 90 89
``````   Console