Generate a sequence with the given operations | function to find minimum required permutation ; Driver code
function StringMatch ( s ) { var lo = 0 , hi = s . length , len = s . length ; var ans = [ ] ; for ( var x = 0 ; x < len ; x ++ ) { if ( s [ x ] == ' ' ) { ans . push ( lo ) ; lo += 1 ; } else { ans . push ( hi ) ; hi -= 1 ; } } ans . push ( lo ) ; document . write ( " " ) ; for ( var i = 0 ; i < ans . length ; i ++ ) { document . write ( ans [ i ] ) ; if ( i != ans . length - 1 ) document . write ( " " ) ; } document . write ( " " ) ; } var S = " " ; StringMatch ( S ) ;