First negative in window
Your task
Given an integer array and window size k, return for each window the first negative number in that window, or 0 if the window has no negative number. Slide the window left to right one step at a time. Use a deque so the whole pass is O(n). Return a list of length len(nums) - k + 1. 1 <= k <= len(nums) <= 10^5.
Examples
first_negative_window(nums: list[int], k: int) -> list[int]Example 1
Input
first_negative_window([12, -1, -7, 8, -15, 30, 16, 28], 3)Output
[-1, -1, -7, -15, -15, 0]