First Negative Integer in Every Window of Size K
Medium

Problem Statement

Given an array and a positive integer k, find the first negative number in every window of size k. If a window does not contain a negative number, print 0 for that window.

Examples

1Example 1
Input:
{ "A": [ -8, 2, 3, -6, 10 ], "K": 2 }
Output:
[ -8, 0, -6, -6 ]
2Example 2
Input:
{ "A": [ 12, -1, -7, 8, -15, 30, 16, 28 ], "K": 3 }
Output:
[ -1, -1, -7, -15, -15, 0 ]
3Example 3
Input:
{ "A": [ 1, 2, 3 ], "K": 2 }
Output:
[ 0, 0 ]
Loading...

Sign in to Run Code and Submit