Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider a greedy strategy.
Let’s start by making the leftmost and rightmost characters match with some number of swaps.
If we figure out how to do that using the minimum number of swaps, then we can delete the leftmost and rightmost characters and solve the problem recursively.