You are viewing a single comment's thread. Return to all comments →
string isValid(string s) {
int c=0; vector<int>vec; unordered_map<char , int>mp; for(int i=0;s[i];i++){ if(mp.find(s[i]) == mp.end()) mp.insert({s[i],1}); else mp[s[i]]++; } for(auto it:mp){ vec.push_back(it.second); } int l=vec[1]; for(int x:vec){ if(x==l) continue; else if(x>l||x<l){ c++; continue; } else return "NO";
} } if(c>1 return "NO"; else 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 →
string isValid(string s) {
} } if(c>1 return "NO"; else return "YES";