#K7916. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
In this problem, you are given a string ( s ). Your task is to determine whether it is possible to rearrange the characters of ( s ) so that the resulting string is a palindrome. A string is considered a palindrome if it reads the same forwards and backwards.
The key observation is that for a string to be rearranged into a palindrome, the frequency of each character (ignoring non-alphabetic characters and case) must satisfy the condition:
(
\sum_{i} (frequency(s_i) \mod 2) \le 1
)
That is, at most one character may appear an odd number of times.
inputFormat
Input will consist of a single line containing the string ( s ). The string may include spaces, punctuation, and mixed case letters. Only alphabetic characters should be considered (i.e., ignore punctuation, spaces, numbers, etc.).
outputFormat
Output a single line: print True
if the input string can be rearranged to form a palindrome, otherwise print False
.## sample
Tact Coa
True