Given a string, find out if its characters can be rearranged to form a palindrome.
Example
For inputString = "aabb", the output should be
palindromeRearranging(inputString) = true.
We can rearrange "aabb" to make "abba", which is a palindrome.
주어진 단어를 재배열 하면 팰린드론 단어가 되는 것 찾기
💡 문제풀이 팁
def palindromeRearranging(inputString):
cnt = 0
for s in set(inputString):
if inputString.count(s) % 2 == 1: #개수가 짝수인 수 여러개, 홀수 1개 abcba이면 가능!
cnt += 1
else:
pass
if cnt > 1: #중복 없는 문자가 하나 이상이면 실패
return False
else:
return True