You are viewing a single comment's thread. Return to all comments →
using namespace std; int test(string s) { map mp; int sum = 0; for(int i = 0; i < s.length(); i++) { mp[s[i]]++; } for(auto it : mp) { if(it.second = 1) { sum += 1; } else if(it.second >= 2) { sum += 2; } } return sum; } int main() { int t; cin >> t; while(t--) { string s; cin >> s; cout << test(s) << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
String Construction
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int test(string s) { map mp; int sum = 0; for(int i = 0; i < s.length(); i++) { mp[s[i]]++; } for(auto it : mp) { if(it.second = 1) { sum += 1; } else if(it.second >= 2) { sum += 2; } } return sum; } int main() { int t; cin >> t; while(t--) { string s; cin >> s; cout << test(s) << endl; } return 0; }