| 3 | #include<iostream> |
| 4 | using namespace std; |
| 5 | int 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 :)) |
nothing calls this directly
no outgoing calls
no test coverage detected