Check if the current character is present in allowed and whether the current frequency is greater than all previous frequencies for this position
if ( freq [ i ] [ j ] > maxfrequency and allowed [ j ] == true ) maxfrequency = freq [ i ] [ j ] ; }