Given a string, find minimum no of swaps(not necessarily adjacent) to convert it into a string which have similar characters side by side.
Input : abcb
Output : 1
Explanation : swap (c, b) to form abbc or acbb. Number of swap operations for this is 1;
Input : abbaacb
Output : 2
Explanation : Swap 0th index with 6th index and then swap 5th index with 6th index.
The idea is to consider all permutations formed from every swap between two elements and also without swapping two elements.
Time Complexity : The recurrence is T(n) = 2n*T(n-1) + O(n)
So the time complexity is greater than O((2*n)!)