When size of String is greater than k to store the frequencies of the characters
Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) if ( freq . ContainsKey ( s [ i ] ) ) { freq [ s [ i ] ] = freq [ s [ i ] ] + 1 ; } else { freq . Add ( s [ i ] , 1 ) ; }