Stores the original index of the characters in sorted order of key
Dictionary < int , List < int > > fre = new Dictionary < int , List < int > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int key = ( int ) ( s [ i ] ) ; List < int > que = new List < int > ( ) ; if ( fre . ContainsKey ( key ) ) { que = fre [ key ] ; } que . Add ( i ) ; fre [ key ] = que ; }