Skip to content
CampusEduX

First Negative Number in Every Window

Mediumjavapythonccppjavascript

Given an integer array and a window size K, find the first negative number in every contiguous window of size K. If a window has no negative number, use 0 for that window.

Input Format

The first line contains two integers N and K. The second line contains N space-separated integers.

Output Format

Print the first negative value from each window (left to right), separated by single spaces.

Related Problems

  • Maximum Element in Every Window
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Two Sum in Sorted Array
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Remove Duplicates Using Two Pointers
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...