#K9231. Minimum Operations to Avoid Consecutive Characters

    ID: 38169 Type: Default 1000ms 256MiB

Minimum Operations to Avoid Consecutive Characters

Minimum Operations to Avoid Consecutive Characters

Given a string (s), you need to determine the minimum number of operations required to make sure that no two consecutive characters are the same. In one operation, you can change any character to any other character such that it becomes different from its neighbor(s).

For instance, if (s = "aaab"), then by performing 2 operations (for example, changing the second and third characters) the string can be modified so that all adjacent characters are distinct.

Your task is to help in computing this minimum number of operations for each test case provided.

inputFormat

The first line contains an integer (T) representing the number of test cases. Each test case consists of two lines: the first line contains an integer (n) (the length of the string), and the second line contains the string (s).

outputFormat

For each test case, output the minimum number of operations required such that no two consecutive characters in the string are identical. Each result should be printed on a new line.## sample

4
3
abc
4
aaab
5
ababa
2
cc
0

2 0 1

</p>