You are viewing a single comment's thread. Return to all comments →
int alternatingCharacters(string s) { if (s.find_first_not_of(s[0]) == string::npos) return s.size()-1; int del = 0; int len = s.size(); for(int i = 0; i<len; i++){ if((i+1)<len && s[i]==s[i+1]){ del++; } } return del; }
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 →