#C7412. Rearrange to Form a Palindrome
Rearrange to Form a Palindrome
Rearrange to Form a Palindrome
Given a string ( s ), determine if it is possible to rearrange its characters to form a palindrome. A string is a palindrome if it reads the same forwards and backwards.
A necessary and sufficient condition for such a rearrangement is that at most one character appears an odd number of times, i.e.,
[
\sum_{c} \bigl[f(c) \bmod 2\bigr] \leq 1
]
If it is possible, output one possible palindrome; otherwise, output "NO".
inputFormat
Input is provided via standard input (stdin) as a single line containing the string ( s ). The string is non-empty and may contain letters.
outputFormat
Print to standard output (stdout) one possible palindrome rearrangement of ( s ) if it exists; otherwise, print "NO".## sample
racecar
racecar