Problem Statement | |||||||||||||
You are given a String s containing only the letters 'a' and 'b'. The letters are arranged in a circle, so the last and first characters are adjacent. You will perform a series of swaps until all the 'a's form one consecutive sequence and all the 'b's form another consecutive sequence. In each swap, you can select any two characters and swap them. Return the minimal number of swaps necessary to reach your goal. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | s will contain between 1 and 15 characters, inclusive. | ||||||||||||
- | s will contain the letters 'a' and 'b' only. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|