【Leetcode_easy】884. Uncommon Words from Two Sentences
problem
884. Uncommon Words from Two Sentences
题意:只要在两个句子中单词出现总次数大于1次即可。
注意掌握istringstream/map/set的使用方法。
solution:
class Solution { public: vector<string> uncommonFromSentences(string A, string B) { vector<string> res; unordered_map<string, int> tmp; istringstream iss(A+" "+B);//err.. while(iss >> A) tmp[A]++; for(auto a:tmp) { if(a.second==1) res.push_back(a.first);//err.. } return res; } };
参考
1. Leetcode_easy_884. Uncommon Words from Two Sentences;
2. grandyang;
3. discuss;
完
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/