leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0884.cpp (466B)


0 class Solution {
1 public:
2 vector<string> uncommonFromSentences(string s1, string s2) {
3 unordered_map<string, int> um;
4 stringstream ss;
5 string t;
7 ss.str(s1);
8 while (ss >> t)
9 um[t]++;
11 ss.str(s2);
12 ss.clear();
13 while (ss >> t)
14 um[t]++;
16 vector<string> res;
17 for (auto &[str, cnt] : um)
18 if (cnt == 1) res.push_back(str);
19 return res;
20 }
21 };