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 ) : NEW_LINE INDENT maxfrequency = freq [ i ] [ j ] NEW_LINE DEDENT