You are viewing a single comment's thread. Return to all comments →
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int t; cin >> t; string str;
while(t) { cin >> str; int i=0, count = 0; while(i < static_cast<int>(str.size()-1)) { if(i>=0 && str[i] == str[i+1]) { str.erase(i,1); count++; // cout << str.size()-1 << " "; i--; } else { i++; } } cout << count << "\n"; t--; } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t; cin >> t; string str;
}