#K45682. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
You are given a string s and you are required to determine if its letters can be rearranged to form a palindrome.
A palindrome is a string that reads the same backward as forward. For a rearrangement of the string to be a palindrome, at most one character may appear an odd number of times, while all other characters must occur an even number of times. Mathematically, if you let \( f(c) \) denote the frequency of character \( c \) in the string, the condition is:
\( \sum_{c} [f(c) \bmod 2 \neq 0] \leq 1 \)
Your task is to check this condition and output True
if the rearrangement into a palindrome is possible, or False
otherwise.
inputFormat
The input consists of a single line containing a non-empty string s. The string contains only visible ASCII characters and does not include whitespace. Note that the string may also be empty, which is considered a valid input.
outputFormat
Output a single line: True
if the characters of the string can be rearranged to form a palindrome, or False
otherwise.
carrace
True