Problem Brief
Minimum Swaps to Make Palindrome
FULLTIMEOA
See Amazon online assessment and hiring insights
Example output is a placeholder. Please ignore it.
You are given a binary string, s, consisting of characters '0' and '1'. Transform this string into a palindrome by performing some operations. In one operation, swap any two characters, s[i] and s[j]. Determine the minimum number of swaps required to make the string a palindrome. If it is impossible to do so, then return -1.
Note: A palindrome is a string that reads the same backward as forward, for example, strings "0", "111", "010", "10101" are palindromes, but strings "001", "10", "11101" are not.
1Example 1
Input
s = "0100101"
Output
1
Explanation
Output is just a placeholder. Lets ignore it for now..