Minimum number of flipped bits
Basic Accuracy: 27.52% Submissions: 5117 Points: 1

Given a string containing 0’s and 1’s. The task is to find out minimum number of bits to be flipped such that 0’s and 1’s will be alternative.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.
Each test case contains a string.

Output:
For each test case, print the minimum number of flipped bits in a new line.

Constraints:
1<=T<=100
1<=|string length|<=104

Example:
Input:
2
0011
011000

Output:
2
3

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.