Traverse the input string again to find minimum number of flips
for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == '0' ) count0 -- ; if ( str [ i ] == '1' ) count1 ++ ; res = Math . Min ( res , count1 + count0 ) ; } return res ; }