#C954. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
You are given a string s. Determine whether the characters of the string can be rearranged to form a palindrome.
A string is a palindrome if it reads the same forwards and backwards. In other words, a rearrangement into a palindrome is possible if and only if at most one character occurs an odd number of times. Mathematically, if we let \(n_i\) be the frequency of the \(i\)-th character, then the condition is:
\(\sum_{i} [n_i \bmod 2 \neq 0] \leq 1\)
Output 1
if the string can be rearranged to form a palindrome, otherwise output 0
.
inputFormat
The input consists of a single line containing the string s
. The string may consist of any characters.
outputFormat
Output a single integer: 1
if it is possible to rearrange the characters of s
to form a palindrome, or 0
otherwise.
civic
1