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.

AnswerBot
4mo
Find the first negative integer in every window of size K in an array.
Iterate through the array using a sliding window approach of size K
For each window, find the first negative integer and add it to ...read more
Help your peers!
Add answer anonymously...
DE Shaw Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Validate Binary Search Tree (BST) You are given a binary tree with 'N' integer n...read more
A Software Developer Intern was asked Q. Candies Distribution Problem Statement Prateek is a kindergarten teacher with a ...read more
A Software Developer Intern was asked Q. Binary Ones Count Problem Develop a program to determine the number of '1's in t...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Validate Binary Search Tree (BST) You are given a binary tree with 'N' integer n...read more
A Software Developer Intern was asked Q2. Candies Distribution Problem Statement Prateek is a kindergarten teacher with a ...read more
A Software Developer Intern was asked Q3. Binary Ones Count Problem Develop a program to determine the number of '1's in t...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

