You are on page 1of 2

EXPERIMENT 1.

NAME: Abhay Thakur

UID: 20BCG1117

CLASS: 20BCG1 SECTION: B

DATE OF PERFORMANCE: 05/09/2022

1. AIM: You are given a string containing characters A and B only. Your task is to change it into a
string such that there are no matching adjacent characters. To do this, you are allowed to delete
zero or more characters in the string. Your task is to find the minimum number of required
deletions.

2. Algorithm/Flowchart:

Step.1:- Take input of the string.

Step.2:- Iterate through the string if you find s[i]==s[i+1] we increase the

value of count by 1 .

Step.3:- Return the value of count .


3. Code:

#include <iostream>

#include<bits/stdc++.h>

using namespace std;

int main()

string s="ABBABBA";

int count=0;

for(int i=0;i<s.size()-1;i++)

if(s[i]==s[i+1]) count++;

cout<<" The minimum number of Delete Operations:-"; cout<<count;

4. Output

You might also like