human
First negative integer in every window of size k | Python3 code for First negative integer in every window of size k.
skip out of window and positive elements.
check if a negative element is found , otherwise use 0.
Driver code"
How can the above be solved in Python?
 ... Can you provide a code to first negative integer in every window of size k and the other steps required?
assistant
#Here is code to first negative integer in every window of size k and the other steps required.
 def printFirstNegativeInteger ( arr , k ) :
	firstNegativeIndex = 0
	for i in range ( k - 1 , len ( arr ) ) :
		while firstNegativeIndex < i and ( firstNegativeIndex <= i - k or arr [ firstNegativeIndex ] > 0 ) :
			firstNegativeIndex += 1
		firstNegativeElement = arr [ firstNegativeIndex ] if arr [ firstNegativeIndex ] < 0 else 0
		print ( firstNegativeElement , end = ' ▁ ' )
if __name__ == " _ _ main _ _ " :
	arr = [ 12 , - 1 , - 7 , 8 , - 15 , 30 , 16 , 28 ]
	k = 3
	printFirstNegativeInteger ( arr , k )