Question
Create a C program that will accept an input sequence of integer value containing digit 1 and 2 only and store in into Array A
Create a C program that will accept an input sequence of integer value containing digit 1 and 2 only and store in into Array A. Your task is to store it into a new array, Array B such that there are no matching adjacent element. To do this, you are allowed to delete zero or more digits in Array A. Your task is to find the minimum number of required deletions.
For example, given the input A=112112 , remove an 1 at positions 0 and 3 to make A=1212 in 2 deletions.
Input Format
The first line contains an integer x, the number of queries.
Constraints
- 1 <= q <=10
- 1<=x<=(10^5)
- Input should only contain 1 and 2
Output Format
For each query, print the minimum number of deletions required on a new line. Use Do=while to repeat the execution of the program
Sample Output
- 1111 - 3 deletion
Sample output
- 22222 - 4 deletion
Sample output
- 12121212 - 0 deletion
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started