4 ms·
A more modern take would use collections.Counter(letters) to extract the letter counts, that avoids traversing the string for each letter count: def anagra
by masklinn 12y ago
A more modern take would use collections.Counter(letters) to extract the letter counts, that avoids traversing the string for each letter count:
def anagram_of_palindrome(letters):
return sum(c % 2 for c in Counter(letters).itervalues()) <= 1