You are viewing a single comment's thread. Return to all comments →
The solution here is to count the number of unique occurrences of the characters, here is the explanation : https://youtu.be/UqqNcIUnsv8
solution 1 : using map
int stringConstruction(string s) { map<char, int> mp; int r = 0; for(int i = 0; i < s.size(); i++) if(!mp[s[i]]){ mp[s[i]] = 1; r++; } return r; }
solution 2 : using set
int stringConstruction(string s) { set<char> se(s.begin(), s.end()); return se.size(); }
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 →
The solution here is to count the number of unique occurrences of the characters, here is the explanation : https://youtu.be/UqqNcIUnsv8
solution 1 : using map
solution 2 : using set