Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You have been given an array of integers 'ARR' and an integer ‘K’. You need to find the first negative integer in each window of size ‘K’.

```
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}
```

Detailed explanation

```
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
```

```
1
9
-10 20 -30 -40 50 60 -70 80 90
3
```

```
-10 -30 -30 -40 -70 -70 -70
```

```
Here the first negative integer in the window of size K = 3 is [-10, -30, -30, -40, -70, -70, -70]
```

```
1
6
-10 20 30 -40 -50 60
2
```

```
-10 0 -40 -40 -50
```

```
Here the first negative integer in the window of size 'K' is [-10, 0, -40, -40, -50]
```