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)


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