← 返回 amazon 的题目列表Minimum Swaps to Make Palindrome
类型:online_judge
Given a string, determine if it can be transformed into a palindrome by swapping adjacent characters. If possible, return the minimum number of swaps needed. The maximum length of the string is 10^5.
Input:
A string containing only lowercase letters.
Output:
An integer representing the minimum number of swaps needed to convert the string into a palindrome if possible.
Otherwise, output -1.
Example
Input
aabb