#K91. Sliding Window Minimum
Sliding Window Minimum
Sliding Window Minimum
Given an array of integers and a window size (k), your task is to compute the minimum element within every contiguous subarray (or sliding window) of size (k). More formally, for an array (a_1, a_2, \dots, a_n), you need to output (min(a_i, a_{i+1}, \dots, a_{i+k-1})) for every valid index (i) where (1 \leq i \leq n-k+1).
Efficient solutions (e.g., using a deque) are expected as the array size can be large.
inputFormat
The input is read from standard input and consists of multiple test cases. The first line contains an integer (T), the number of test cases. Each test case consists of two lines:
1. The first line of a test case contains two integers (n) and (k) where (n) is the number of elements in the array and (k) is the size of the sliding window.
2. The second line contains (n) space-separated integers representing the array elements. Note that if (n = 0), the second line will be empty.
outputFormat
For each test case, output a single line containing (n-k+1) space-separated integers representing the minimum of each sliding window. If the array is empty (i.e. (n = 0)) or if no window can be formed, output an empty line.## sample
1
10 4
8 5 10 7 9 4 15 12 90 13
5 5 4 4 4 4 12
</p>