Stores the original index of the characters in sorted order of key
fre = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT key = ( ord ) ( s [ i ] ) NEW_LINE if key in fre : NEW_LINE INDENT que = fre [ key ] NEW_LINE DEDENT else : NEW_LINE INDENT que = collections . deque ( [ ] ) NEW_LINE DEDENT que . append ( i ) NEW_LINE fre [ key ] = que NEW_LINE DEDENT