human
Longest subarray of non | Function to find the maximum length of a subarray of 1 s after removing at most one 0.
Stores the count of consecutive 1 's from left.
Stores the count of consecutive 1 's from right.
Traverse left to right.
If cell is non - empty.
Increase count.
If cell is empty.
Store the count of consecutive 1 's  till (i - 1)-th index.
Traverse from right to left.
Store the count of consecutive 1 s till ( i + 1 ) - th index.
Stores the length of longest subarray.
Store the maximum.
If array a contains only 1 s return n else return ans.
Driver code"
Solution in Python:
assistant
#Here is code to longest subarray of non and the other steps required.
 def longestSubarray ( a , n ) :
	l = [ 0 ] * ( n )
	r = [ 0 ] * ( n )
	count = 0
	for i in range ( n ) :
		if ( a [ i ] == 1 ) :
			count += 1
		else :
			l [ i ] = count
			count = 0
	count = 0
	for i in range ( n - 1 , - 1 , - 1 ) :
		if ( a [ i ] == 1 ) :
			count += 1
		else :
			r [ i ] = count
			count = 0
	ans = - 1
	for i in range ( n ) :
		if ( a [ i ] == 0 ) :
			ans = max ( ans , l [ i ] + r [ i ] )
	return ans < 0 and n or ans
arr = [ 0 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 ]
n = len ( arr )
print ( longestSubarray ( arr , n ) )