1class Solution {2public:3vector<string> subdomainVisits(vector<string> &cpdomains) {4vector<string> v;5unordered_map<string, int> m;6for (auto it : cpdomains) {7string rep = "";8int i = 0;9while (it[i] != ' ') {10rep += (it[i]);11i++;12}13int r = stoi(rep);14m[it.substr(i + 1, it.size())] += r;1516while (it[i] != '.') {17i++;18}19m[it.substr(i + 1, it.size())] += r;20i++;21while (i < it.size() and it[i] != '.') {22i++;23}24if (i != it.size()) {25m[it.substr(i + 1, it.size())] += r;26}27}2829for (auto it : m) {30string a = it.first;31string b = to_string(it.second);32a = b + " " + a;33v.push_back(a);34}35return v;36}37};