#C5305. Minimum Card Flips Problem
Minimum Card Flips Problem
Minimum Card Flips Problem
You are given a string consisting of characters 'R' and 'B'. Each character represents a card that shows either a red or blue face. Your task is to determine the minimum number of flips required to make all cards show the same color. A flip changes a card from 'R' to 'B' or from 'B' to 'R'.
In mathematical terms, if we let \(n_R\) be the number of 'R' cards and \(n_B\) be the number of 'B' cards, the answer is \(\min(n_R,n_B)\).
The input consists of multiple test cases. For each test case, you are given a single string and you should output the minimum number of flips required to make all cards identical.
inputFormat
The first line contains a single integer \(T\) representing the number of test cases.
Each of the following \(T\) lines contains a string \(S\) consisting only of the characters 'R' and 'B'.
\(1 \leq T \leq 1000\) and the length of \(S\) is between 1 and 1000.
outputFormat
For each test case, output a single integer on a new line representing the minimum number of flips required to make all the cards show the same color.
## sample3
RBRB
RRBB
BBBB
2
2
0
</p>