The watchmen of Codetikki scan the horizon through a window of fixed size k, sliding it across a row of mountain heights. At each position, they record the tallest peak visible in the window. Given an array of integers and a number k, compute the maximum value of each subarray of length k. Output the maximums as space-separated integers in O(n) time.
Example 1:
Example 2:
Constraints:
1 <= k <= n <= 10^5 -10^9 <= arr[i] <= 10^9
Tags:
