iterate and mark the frequencies of all characters in str1
for i in range ( l1 ) : NEW_LINE INDENT freq [ ord ( str1 [ i ] ) - ord ( " a " ) ] += 1 NEW_LINE DEDENT for i in range ( l2 ) : NEW_LINE INDENT freq2 [ ord ( str2 [ i ] ) - ord ( " a " ) ] += 1 NEW_LINE DEDENT count = sys . maxsize NEW_LINE