human
Find length of longest substring with at most K normal characters | Function to find maximum length of normal substrings.
keeps count of normal characters.
indexes of substring.
maintain length of longest substring with at most K normal characters.
get position of character.
check if current character is normal.
check if normal characters count exceeds K.
update answer with substring length.
get position of character.
check if character is normal then decrement count.
Driver code.
initialise the string"
Solution in Python:

=====
What is a code to find length of longest substring with at most K normal characters and the other steps required?
assistant
#Here is code to find length of longest substring with at most K normal characters and the other steps required.
 def maxNormalSubstring ( P , Q , K , N ) :
	if ( K == 0 ) :
		return 0
	count = 0
	left , right = 0 , 0
	ans = 0
	while ( right < N ) :
		while ( right < N and count <= K ) :
			pos = ord ( P [ right ] ) - ord ( ' a ' )
			if ( Q [ pos ] == '0' ) :
				if ( count + 1 > K ) :
					break
				else :
					count += 1
			right += 1
			if ( count <= K ) :
				ans = max ( ans , right - left )
		while ( left < right ) :
			pos = ord ( P [ left ] ) - ord ( ' a ' )
			left += 1
			if ( Q [ pos ] == '0' ) :
				count -= 1
			if ( count < K ) :
				break
	return ans
if ( __name__ == " _ _ main _ _ " ) :
	P = " giraffe "
	Q = "01111001111111111011111111"
	K = 2
	N = len ( P )
	print ( maxNormalSubstring ( P , Q , K , N ) )