Calculating prefix sum over this frequency array to get frequency of a character in a range [ L , R ] .
for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { f [ i ] [ j ] += f [ i ] [ j - 1 ] ; } } }