In - place remove non - repeating characters from the string
int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str [ i ] ] > 1 ) str . Replace ( str [ k ++ ] , str [ i ] ) ; str . Replace ( str [ k ] , ' \0' ) ;