First Negative Integer in Every Window of Size K
Given an array of integers 'ARR' and an integer 'K', determine the first negative integer in every contiguous subarray (or window) of size 'K'. If a window does not contain a negative integer, the output for that window should be 0.
Input:
T
N
arr[0] arr[1] ... arr[N-1]
K
Output:
Output for each test case should be the first negative integer in each window of size K, separated by a space.
Example:
Input:
1
9
-10 20 -30 -40 50 60 -70 80 90
3
Output:
-10 -30 -30 -40 -70 -70 -70
Constraints:
- 1 <= T <= 102
- 1 <= N <= 103
- -104 <= data <= 104
- 1 <= K <= N
Note: You do not need to print anything; focus on implementing the function as instructed.
Be the first one to answer
Add answer anonymously...
Top DE Shaw Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app