Finding frequency of each character
for ( let i = 0 ; i < S . length ; ++ i ) { if ( freq [ S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) count ++ ; freq [ S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; }