#C13982. Palindrome Permutation Checker
Palindrome Permutation Checker
Palindrome Permutation Checker
This problem requires you to determine whether each given string can be rearranged to form a palindrome. A palindrome is a string that reads the same forwards and backwards. A key observation is that a string can be rearranged into a palindrome if and only if at most one character has an odd frequency. Formally, for a string \( s \), let \( f(c) \) be the number of occurrences of character \( c \). Then \( s \) can be permuted into a palindrome if
\( \sum_{c} [f(c) \bmod 2] \le 1 \)
Your task is to write a program that, given a list of strings, outputs True
for each string that can be rearranged into a palindrome and False
otherwise.
inputFormat
The first line contains an integer \( N \), the number of strings.
Each of the following \( N \) lines contains one string. Note that a string may be empty.
outputFormat
For each input string, output True
if it can be rearranged to form a palindrome, otherwise output False
. Each result should be printed on a new line.
5
civic
ivicc
hello
aabb
racecar
True
True
False
True
True
</p>