Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

LO4 Specify how to design a training program for adult learners.

Answered: 1 week ago