Untitled
unknown
plain_text
8 months ago
341 B
1
Indexable
Never
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; } };
Leave a Comment