Unique Adjacent Characters
Easy
4
33.3% Acceptance
Coder at Codedamn has a binary sequence of length . Coder can execute the following adjustment on :
- Append any digit ( or ) into any spot within .
Determine the least number of adjustments Coder must implement so that doesn't have any adjacent matching digits.
Input Format
- The initial line contains a single integer — the count of scenarios to evaluate. Following are the scenarios.
- The first line in each scenario presents an integer — the length of the binary sequence .
- The subsequent line in each scenario showcases a binary sequence of length , consisting solely of s and s.
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 are identical.
Limitations
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: .
Scenario 2: No adjustments are needed.
Scenario 3: These adjustments can be executed: .