human
Find zeroes to be flipped so that number of consecutive 1 's is maximized | m is maximum of number zeroes allowed to flip , n is size of array.
Left and right indexes of current window.
Left index and size of the widest window.
Count of zeroes in current window.
While right boundary of current window doesn 't cross right end.
If zero count of current window is less than m , widen the window toward right.
If zero count of current window is more than m , reduce the window from left.
Updqate widest window if this window size is more.
Print positions of zeroes in the widest window.
Driver program"
Solution in Python:
 ... Write me a code to find zeroes to be flipped so that number of consecutive 1 's is maximized and the other steps required?
assistant
#Here is code to find zeroes to be flipped so that number of consecutive 1 's is maximized and the other steps required.
 def findZeroes ( arr , n , m ) :
	wL = wR = 0
	bestL = bestWindow = 0
	zeroCount = 0
	while wR < n :
		if zeroCount <= m :
			if arr [ wR ] == 0 :
				zeroCount += 1
			wR += 1
		if zeroCount > m :
			if arr [ wL ] == 0 :
				zeroCount -= 1
			wL += 1
		if ( wR - wL > bestWindow ) and ( zeroCount <= m ) :
			bestWindow = wR - wL
			bestL = wL
	for i in range ( 0 , bestWindow ) :
		if arr [ bestL + i ] == 0 :
			print ( bestL + i , end = " ▁ " )
arr = [ 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 1 ]
m = 2
n = len ( arr )
print ( " Indexes ▁ of ▁ zeroes ▁ to ▁ be ▁ flipped ▁ are " , end = " ▁ " )
findZeroes ( arr , n , m )