MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Codeforces_problems/ABBB/soultion.cpp:5–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include<iostream>
4using namespace std;
5int main()
6{
7 ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);//make input output operation faster
8 int t; cin >> t; //take the input
9 while (t--)
10 {
11 string s;
12 cin >> s; //take the input as string
13 for (int i = 1; i < s.length(); i++) {
14 if ((s[i] == 'B' && s[i - 1] == 'A') || (s[i] == 'B' && s[i - 1] == 'B')) { //iterate over the string to find a "AB" or "BB"
15 s.erase(s.begin() + i - 1, s.begin() + i + 1); //delete them
16 i -= 2; //make the counter smaller
17 }
18 }
19 cout << s.size() << endl; //printing the length of the string
20 }
21 return 0;
22}
23//Happy Coding :))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected