Canonical Palindrome
Rearrange the characters of S into a palindrome, or print NO SOLUTION. To make the answer unique, output the palindrome whose first half is SORTED alphabetically (the odd-count character, if any, goes in the middle).
Input: one line with a lowercase string.
Output: the canonical palindrome, or NO SOLUTION.
Constraints:
- 1 ≤ |S| ≤ 105
Sample Tests
Input 1
aabbc
Output 1
abcba
Input 2
aabbcd
Output 2
NO SOLUTION
Discussion (opens after you solve — no spoilers before)
No comments yet.