#C11181. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
You are given a string s consisting only of lowercase letters. Your task is to determine whether it is possible to rearrange the characters of s such that the resulting string forms a palindrome.
A palindrome is a string that reads the same forwards and backwards. In mathematical terms, for a string of length n, it can be rearranged into a palindrome if and only if at most one character appears an odd number of times. More formally, let \( c_i \) be the count of the i-th character, then a necessary and sufficient condition is:
[ \sum_{i=1}^{26} \left( c_i \bmod 2 \right) \leq 1 ]
Read the input from stdin and output the answer to stdout. Output True
if the string can be rearranged into a palindrome; otherwise, output False
.
inputFormat
The input consists of a single line containing a string s composed only of lowercase English letters.
Example:
aabb
outputFormat
Output a single line: True
if the string can be rearranged to form a palindrome, and False
otherwise.
Example:
True## sample
aabb
True