We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
fromcollectionsimportCounterdefgameOfThrones(s):# Complete this functionnum_odd=0s1=Counter(s)foreachins1.values():ifeach%2!=0:num_odd+=1# when num_odd > 1, not palindromeifnum_odd>1:return'NO'return('YES')
Game of Thrones - I
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.