【Leetcode_easy】811. Subdomain Visit Count
problem
solution:
class Solution { public: vector<string> subdomainVisits(vector<string>& cpdomains) { vector<string> res; unordered_map<string, int> subdomain; int spaceIdx = 0; for(auto cpdomain:cpdomains) { spaceIdx = cpdomain.find(" ");//errrrr... int cnt = stoi(cpdomain.substr(0, spaceIdx)); string tmp = cpdomain.substr(spaceIdx+1); for(int i=0; i<tmp.size(); ++i) { if(tmp[i]=='.') subdomain[tmp.substr(i+1)] += cnt;//errr. } subdomain[tmp] += cnt;//err.. } for(auto sub:subdomain) { res.push_back(to_string(sub.second) + " " + sub.first);//errr... } return res; } };
参考
1. Leetcode_easy_811. Subdomain Visit Count;
2. Grandyang;
完
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/