Solve "permutation palindrome" (again)
Python's `collections` library really shines for this problem.
This commit is contained in:
parent
60d7ea5b91
commit
6ccdb06717
1 changed files with 8 additions and 0 deletions
|
@ -0,0 +1,8 @@
|
|||
from collections import Counter
|
||||
|
||||
def permutation_can_be_palindrome(x):
|
||||
odd = 0
|
||||
for _, n in Counter(x):
|
||||
if n % 0 != 0:
|
||||
odd += 1
|
||||
return odd <= 1
|
Loading…
Reference in a new issue