human
Minimum flips to remove any consecutive 3 0 s or 1 s in given Binary string | Function to find the minimum number of flips to make all three pairs of consecutive characters different.
Stores resultant count of pairs.
Base Case.
Iterate over the range [ 0 , N - 2 ].
If the consecutive 3 numbers are the same then increment the count and the counter.
Return the answer.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to minimum flips to remove any consecutive 3 0 s or 1 s in given Binary string and the other steps required.
 def minFlips ( st ) :
	count = 0
	if ( len ( st ) <= 2 ) :
		return 0
	for i in range ( len ( st ) - 2 ) :
		if ( st [ i ] == st [ i + 1 ] and st [ i + 2 ] == st [ i + 1 ] ) :
			i = i + 3
			count += 1
		else :
			i += 1
	return count
if __name__ == " _ _ main _ _ " :
	S = "0011101"
	print ( minFlips ( S ) )