Given a string, what is the minimum number of adjacent swaps required to convert a string into a palindrome. If not possible, return -1
.
Example 1:
Input: "mamad"
Output: 3
Example 2:
Input: "asflkj"
Output: -1
Example 3:
Input: "aabb"
Output: 2
Example 4:
Input: "ntiin"
Output: 1
Explanation: swap 't' with 'i' => "nitin"