text: Counting the frequency of all character using Counter function
code: Map < Character , Integer > freq = new HashMap < Character , Integer > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! freq . containsKey ( s . charAt ( i ) ) ) freq . put ( s . charAt ( i ) , 0 ) ; freq . put ( s . charAt ( i ) , freq . get ( s . charAt ( i ) ) + 1 ) ; }