Neighbor Swaps to a Mirror
A mirror is a string that reads the same from both ends. The letters of text can be put in an order that is a mirror. One move swaps two letters that are next to each other.
Return the fewest moves that turn text into a mirror.
Example 1
text "abab"
returns 1
Swap the last two letters: abab becomes abba.
Example 2
text "abbac"
returns 2
Two swaps: abbac, abbca, abcba. The c has no partner, so it ends in the middle.
Constraints
1 <= len(text) <= 60textholds lowercase letters- some order of the letters of
textis a mirror
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.