function to find minimum required permutation
void StringMatch ( string s ) { int lo = 0 , hi = s . length ( ) , len = s . length ( ) ; vector < int > ans ; for ( int x = 0 ; x < len ; x ++ ) { if ( s [ x ] == ' I ' ) { ans . push_back ( lo ) ; lo += 1 ; } else { ans . push_back ( hi ) ; hi -= 1 ; } } ans . push_back ( lo ) ; cout << " [ " ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] ; if ( i != ans . size ( ) - 1 ) cout << " , " ; } cout << " ] " ; }