Given a binary string S which only contains '0' and '1' such that the '0' or '1' at the 1st position is just next to '0' or '1' at the last position i.e. string is cyclic. Your task is to re arrange the string such that all the '1' in the string are next to each other (Note : the string is cyclic ).
You can choose any '1' in the string and swap its position with the first '1' in any of the two direction.
Find the minimum number of moves in which the task can be done.
First line of the test case contains an integer T, denoting number of test cases. Following T lines contains a string S each.
For each of the test case print the answer in separate lines.
1 <= T < 103
1 <= |S| <= 104
S will consist of only '0' and '1'.
S will contain minimum of one '1'.
In the first move 010110101 is changed to 010110110. In the second move 010110110 is changed to 010111100. In the third move 010111100 is change to 001111100.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.