Professional Documents
Culture Documents
Sheru Ap 1.3
Sheru Ap 1.3
Sheru Ap 1.3
UID: 20BCG1103
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.2:- Iterate through the string if you find s[i]==s[i+1] we increase the
value of count by 1 .
#include <iostream>
#include<bits/stdc++.h>
int main()
string s="ABBABBA";
int count=0;
for(int i=0;i<s.size()-1;i++)
if(s[i]==s[i+1]) count++;
4. Output