Minimum number of characters to be removed to make a binary string alternate | C # program to find minimum number of characters to be removed to make a string alternate . ; Returns count of minimum characters to be removed to make s alternate . ; if two alternating characters of string are same ; result ++ ; then need to delete a character ; Driver code
using System ; public class GFG { static int countToMake0lternate ( string s ) { int result = 0 ; for ( int i = 0 ; i < ( s . Length - 1 ) ; i ++ ) if ( s [ i ] == s [ i + 1 ] ) return result ; } static public void Main ( ) { Console . WriteLine ( countToMake0lternate ( "000111" ) ) ; Console . WriteLine ( countToMake0lternate ( "11111" ) ) ; Console . WriteLine ( countToMake0lternate ( "01010101" ) ) ; } }