You are viewing a single comment's thread. Return to all comments →
Merge odd and even situations.
That means regardless the len(str) is odd or even, just when the count of each elements have no more than ONE, the str is palindrome.
from collections import Counter
# Complete this function
num_odd = 0
s1 = Counter(s)
for each in s1.values():
if each % 2 != 0:
num_odd += 1
# when num_odd > 1, not palindrome
if num_odd > 1: