Function to check if a string contains equal number of one and zeros or not
static bool isValid ( string p ) { int n = p . Length ; int c1 = 0 , c0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] == '0' ) { c0 ++ ; } if ( p [ i ] == '1' ) { c1 ++ ; } } if ( c0 == c1 ) { return true ; } else { return false ; } }