Function to return the frequency array for the given string
function getFrequencies ( str ) { let freq = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) freq [ i ] = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } return freq ; }