原题链接:https://leetcode-cn.com/problems/uncommon-words-from-two-sentences/
class Solution {
public:
vector<string> uncommonFromSentences(string s1, string s2) {
vector<string> res;
unordered_map<string, int> mp;
auto insert = [&](string str) {
string s;
istringstream ss(str);
while (getline(ss, s, ' ')) {
mp[s]++;
}
};
insert(s1);
insert(s2);
for (auto &x : mp) {
if (x.second == 1) {
res.emplace_back(x.first);
}
}
return res;
}
};