#C6187. Smallest Palindromic Permutation
Smallest Palindromic Permutation
Smallest Palindromic Permutation
Given a string s consisting of lowercase letters, your task is to determine whether any permutation of the characters can form a palindrome. If such a permutation exists, output the lexicographically smallest palindromic permutation. Otherwise, output "-1".
A palindrome is a string that reads the same backward as forward. To form a palindromic permutation, at most one character can have an odd frequency.
Hint: Count the frequency of each character and try to build the palindrome by placing half of the characters in increasing order, then mirror them. If there is a unique character with an odd frequency, place it in the middle.
inputFormat
The input consists of a single line containing a string s (1 ≤ |s| ≤ 105) that contains only lowercase English letters.
outputFormat
Output a single line containing the lexicographically smallest palindromic permutation of s if it exists, or "-1" if it is not possible to form a palindrome.
## sampleaabb
abba
</p>