[Solution] Different Consecutive Characters CodeChef Solution
Problem
Chef has a binary string of length . Chef can perform the following operation on :
- Insert any character ( or ) at any position in .
Find the minimum number of operations Chef needs to perform so that no two consecutive characters are same in .
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — the length of the binary string .
- The second line of each test case contains a binary string of length containing s and s only.
Output Format
For each test case, output on a new line the minimum number of operations Chef needs to perform so that no two consecutive characters are same in .
👇👇👇👇👇
Explanation:
Test case 1: We can perform the following operations: .
Test case 2: We do not need to perform any operations.
Test case 3: We can perform the following operations: .
No comments:
Post a Comment