Sliding Window Maximum

easy
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.

Input Format

first line contains integer N and K denoting the size of array and size of window. second line contains n integer of array. Input is handled for you.

Output Format

Return your answer in form of array. Output is handled for you.

Constraints

1<= N <= 10^4
 1<= K <= N

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
8 3
1 3 -1 -3 5 3 6 7
Output
3 3 5 5 6 7
Previous
Stock Span
Next
Duplicate Brackets

Related Questions