Untitled
unknown
plain_text
2 years ago
341 B
8
Indexable
class Solution {
public:
int removeAlmostEqualCharacters(string word) {
int ans=0;
int n=word.size();
for(int i=1;i<n;i++){
if(word[i-1]=='*') continue;
if(abs(word[i] -word[i-1])<=1){
ans++;
word[i]='*';
}
}
return ans;
}
};Editor is loading...
Leave a Comment