You are viewing a single comment's thread. Return to all comments →
Passes all test cases and removes maximum one character
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; int main() { string s; cin >> s; vector<int> v(26,0); for(char i : s) v[(int)(i - 'a')]++; sort(v.begin(), v.end()); v.erase(remove(v.begin(), v.end(),0) , v.end()); if(v.back()==v.front()) cout<<"YES\n"; else if((v.back()-v.front()==1)&&(v[(int)v.size()-1]!=v[(int)v.size()-2])) cout<<"YES\n"; else if(v[0]==1 && v[1]!= 1) cout<<"YES\n"; else cout<<"NO\n"; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Concatenate
You are viewing a single comment's thread. Return to all comments →
Passes all test cases and removes maximum one character