When m = n - 1
else if ( Math . abs ( n - m ) <= 1 ) { while ( n > 0 && m > 0 ) { System . out . print ( "01" ) ; n -- ; m -- ; } if ( n != 0 ) { System . out . print ( "0" ) ; } if ( m != 0 ) { System . out . print ( "1" ) ; } } else { while ( m - n > 1 && n > 0 ) { System . out . print ( "110" ) ; m = m - 2 ; n = n - 1 ; } while ( n > 0 ) { System . out . print ( "10" ) ; n -- ; m -- ; } while ( m > 0 ) { System . out . print ( "1" ) ; m -- ; } } }