Stores the original index of the characters in sorted order of key
let fre = new Map ( ) ; for ( let i = 0 ; i < N ; i ++ ) { let key = s [ i ] . charCodeAt ( ) ; let que = [ ] ; if ( fre . has ( key ) ) { que = fre [ key ] ; } que . push ( i ) ; fre [ key ] = que ; }