Unique Adjacent Characters

Easy
4
33.3% Acceptance

Coder at Codedamn has a binary sequence SS of length NN. Coder can execute the following adjustment on SS:

  • Append any digit (00 or 11) into any spot within SS.

Determine the least number of adjustments Coder must implement so that SS doesn't have any adjacent matching digits.

Input Format

  • The initial line contains a single integer TT — the count of scenarios to evaluate. Following are the scenarios.
  • The first line in each scenario presents an integer NN — the length of the binary sequence SS.
  • The subsequent line in each scenario showcases a binary sequence SS of length NN, consisting solely of 00s and 11s.

Output Format

For every scenario, print on a new line the minimal number of adjustments Coder needs to make to ensure no adjacent digits in SS are identical.

Limitations

  • 1T1001 \leq T \leq 100
  • 1N10001 \le N \le 1000

Example Test Cases (with explanation)

Scenario #1:

Input:

3 2 11 4 0101 5 00100

Output:

1 0 2

Explanation

Scenario 1: The following adjustments can be made: 1110111 \rightarrow 1\underline{0}1.

Scenario 2: No adjustments are needed.

Scenario 3: These adjustments can be executed: 00100010100010101000100 \rightarrow 0\underline{1}0100 \rightarrow 01010\underline{1}0.