class Solution {
public:
vector<string> uncommonFromSentences(string A, string B) {
vector<string> ret;
vector<string> v(100, "");
unordered_map<string, int> um;
A = A + ' ' + B;
int index = 0;
for (const auto& e : A) {
if (e == ' ') {
++index;
}
else {
v[index].push_back(e);
}
}
for (const auto& e : v) {
if (e != "")
++um[e];
else
break;
}
for (const auto& e : um) {
if (e.second == 1)
ret.push_back(e.first);
}
return ret;
}
};
转载请注明原文地址:https://blackberry.8miu.com/read-7716.html