


If a window does not contain a negative integer, then print 0 for that window.
If N = 9, arr[ ] = {-10, 20, -30, -40, 50, 60, -70, 80, 90} and K = 3
then the output will be
{-10 -30 -30 -40 -70 -70 -70}
The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then the test cases are as follows.
The first line of each test case contains an integer ‘N’ which denotes the size of the array.
The second line of each test case contains elements of the array. The line consists of values of elements of the array separated by a single space.
The third line of each test case contains an integer ‘K’ which denotes the window size.
For each test case, print the first negative integer in each window of size ‘K’ separated by a space.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10^2
1 <= N <= 10^3
-10^4 <= data <= 10^4
1 <= K <= N
Where ‘N’ is the size of the array, “data” is the value of the element of the array 'ARR' and ‘K’ is the window size.
Time Limit: 1 sec
Run two loops. In the outer loop, take all windows of size ‘K’.
In the inner loop, get the first negative integer of the current window.
Consider one window of size ‘K’ at a time.
Take a variable ‘firstNegativeIndex’ to keep track of the index of the first negative element in each window of size ‘K’.
After sliding the window one step ahead, we skip the elements which no longer fall under the current k size window as well as the positive elements.