class Solution {
public:
vector<string> uncommonFromSentences(string s1, string s2) {
unordered_map<string,int> mp;
vector<string> ans;
string s;
stringstream a,b;
a<<s1;b<<s2;
while(a>>s)mp[s]++;
while(b>>s)mp[s]++;
for(auto m:mp){
if(m.second==1){
ans.push_back(m.first);
}
}
return ans;
}
};
C++中stringstream运用读入字符串句子中的单词
最新推荐文章于 2024-02-27 21:21:53 发布