Maximum in Subarray

4

6 votes
Easy
Problem

Given an array A and an integer K, Find the maximum number for each and every contiguous subarray of size K.

INPUT

First line contains two integers N and K denoting the size of array and size of subarray.

Second line contains N integers denoting the array.
 

OUTPUT

Print N-K+1 denoting maximum number in each of the subarrays.

CONSTRAINTS

1N105

1KN

1Ai106

Time Limit: 0.5
Memory Limit: 256
Source Limit:
Editor Image

?