Store frequency of all characters in the string
Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; foreach ( char ch in str . ToCharArray ( ) ) { mp [ ch ] = mp . GetValueOrDefault ( ch , 0 ) + 1 ; }