Given a string of lowercase characters. Find the count of characters which only occured once in the string.
Show Answer
int solve(string s) {
sort(s.begin(),s.end());
int unik = 0;
int cnt = 1;
for(int i=1;i<s.size();i++){
if( s[i] != s[i-1] ){
unik += (cnt == 1);
cnt = 0;
}
cnt++;
}
unik += (cnt == 1);
return unik;
}