#K35977. Minimum Changes to Avoid Adjacent Repetition
Minimum Changes to Avoid Adjacent Repetition
Minimum Changes to Avoid Adjacent Repetition
You are given t test cases. In each test case, you are given a string. Your task is to determine the minimum number of changes required so that no two adjacent characters in the string are identical.
For a given string s of length n, you need to compute the answer using the formula:
$$\text{ans} = \sum_{i=2}^{n} \mathbf{1}_{\{s_i = s_{i-1}\}} $$where \( \mathbf{1}_{\{s_i = s_{i-1}\}} \) equals 1 if \( s_i = s_{i-1} \) and 0 otherwise.
Print the answer for each test case on a new line.
inputFormat
The first line contains an integer t — the number of test cases.
Each of the next t lines contains a non-empty string consisting of lowercase English letters.
outputFormat
For each test case, output a single line containing the minimum number of changes required so that no two adjacent characters are the same.
## sample3
aabb
ab
aaaa
2
0
3
</p>