You are viewing a single comment's thread. Return to all comments →
C++
string isValid(string s) { map<int, int> m; for(auto c : s){ m[c] += 1; } int n = -1; int ignore = 1; for(auto it=m.begin(); it!=m.end(); ++it){ if(n < 0) n = it->second; else if(n == it->second){ } else { if(ignore > 0){ ignore--; } else return "NO"; } } return "YES"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and the Valid String
You are viewing a single comment's thread. Return to all comments →
C++