#C2514. Sliding Window Maximum
Sliding Window Maximum
Sliding Window Maximum
Given an array of integers and an integer k, your task is to determine the maximum value in each contiguous subarray (or sliding window) of size k as the window moves from left to right.
Formally, for an array \(a_1, a_2, \dots, a_n\) and a window size \(k\), you need to compute:
[ \max_{0 \leq j < k} {a_{i+j}} ]
for each valid starting index \(i\) (with \(1 \leq i \leq n-k+1\)).
If the input array is empty or k is 0, output an empty result.
inputFormat
The input is given from stdin in the following format:
- An integer n representing the number of elements in the array.
- A line containing n space-separated integers.
- An integer k representing the size of the sliding window.
outputFormat
Output the maximum values of each sliding window as a sequence of space-separated integers to stdout.
## sample8
1 3 -1 -3 5 3 6 7
3
3 3 5 5 6 7