#K81897. Can Form Palindrome?
Can Form Palindrome?
Can Form Palindrome?
You are given a string s consisting of lowercase English letters. Your task is to determine whether it is possible to rearrange the characters of s to form a palindrome.
If it is possible, you are required to output YES
on the first line and one valid palindrome configuration obtained by rearranging the characters of s on the second line. Otherwise, print NO
on a single line.
A string is a palindrome if it reads the same backwards as forwards. Formally, a string p is a palindrome if
where \( p^R \) denotes the reverse of string \( p \). You are allowed to output any one valid palindrome if there are multiple.
inputFormat
The input consists of a single line containing the string s (1 ≤ |s| ≤ 105), where |s| denotes the length of the string. The string contains only lowercase English letters.
outputFormat
If it is possible to rearrange the string into a palindrome, print YES
on the first line and the resulting palindrome on the second line. Otherwise, print NO
.
aaabb
YES
ababa
</p>