text: Maximize the decimal equivalent by flipping only a contiguous set of 0 s | C # implementation to maximize the value of the decimal equivalent given in the binary form ; Function to print the binary number ; Check if the current number is 0 ; Find the continuous 0 s ; Replace initially occurring 0 with 1 ; Break out of loop if 1 occurs ; Driver code
code: using System ; class GFG { static String flip ( char [ ] s ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '0' ) { while ( s [ i ] == '0' ) { s [ i ] = '1' ; i ++ ; } break ; } } return new String ( s ) ; } public static void Main ( String [ ] args ) { String s = "100010001" ; Console . WriteLine ( flip ( s . ToCharArray ( ) ) ) ; } }