human
Count of non | Function to return the count of required non - overlapping sub - strings.
To store the required count.
If "010" matches the sub - string starting at current index i.
If "101" matches the sub - string starting at current index i.
Driver code"
Solution in Python:
assistant
#Here is code to count of non and the other steps required.
 def countSubStr ( s , n ) :
	count = 0 ;
	i = 0
	while i < ( n - 2 ) :
		if ( s [ i ] == '0' and s [ i + 1 ] == '1' and s [ i + 2 ] == '0' ) :
			count += 1 ;
			i += 3 ;
		elif ( s [ i ] == '1' and s [ i + 1 ] == '0' and s [ i + 2 ] == '1' ) :
			count += 1 ;
			i += 3 ;
		else :
			i += 1 ;
	return count ;
if __name__ == " _ _ main _ _ " :
	s = "10101010101" ;
	n = len ( s ) ;
	print ( countSubStr ( s , n ) ) ;