Deletions of "01" or "10" in binary string to make it free from "01" or "10" | C # implementation of the approach ; Function to return the count of deletions of sub - strings "01" or "10" ; To store the count of 0 s and 1 s ; Driver code
using System ; class GFG { static int substrDeletion ( string str , int len ) { int count0 = 0 , count1 = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) count0 ++ ; else count1 ++ ; } return Math . Min ( count0 , count1 ) ; } public static void Main ( ) { string str = "010" ; int len = str . Length ; Console . Write ( substrDeletion ( str , len ) ) ; } }