text: Maximize the decimal equivalent by flipping only a contiguous set of 0 s | 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: function flip ( s ) { for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == ' ' ) { while ( s [ i ] == ' ' ) { s [ i ] = ' ' ; i ++ ; } break ; } } return s . join ( " " ) ; } let s = " " ; document . write ( flip ( s . split ( ' ' ) ) ) ;