Minimum number of characters to be removed to make a binary 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
function countToMake0lternate ( s ) { let result = 0 ; for ( let i = 0 ; i < ( s . length - 1 ) ; i ++ ) if ( s [ i ] == s [ i + 1 ] ) return result ; } document . write ( countToMake0lternate ( " " ) + " " ) ; document . write ( countToMake0lternate ( " " ) + " " ) ; document . write ( countToMake0lternate ( " " ) + " " ) ;