Finding Uncommon Words in Two Sentences Using Hash Maps
IntuitionThe problem requires identifying words that appear exactly once in one of the two sentences and do not appear in the other sentence. My first thought w
# Intuition
The problem requires identifying words that appear exactly once in one of the two sentences and do not appear in the other sentence. My first thought was to use hash maps (or dictionaries) to count the frequency of each word in both sentences and then find words that meet the criteria.

# Approach
1. Split Sentences into Words: Split both sentences s1 and s2 into individual words.
2. Count Word Frequencies: Use two hash maps (mop1 and mop2) to count the frequency of each word in s1 and s2, respectively.
3. Identify Uncommon Words:
    - Iterate through the words in s1 and check if they appear exactly once in s1 and do not appear in s2.
    - Similarly, iterate through the words in s2 and check if they appear exactly once in s2 and do not appear in s1.
4. Collect Uncommon Words: Add the uncommon words to the result list.
5. Return Result: Return the list of uncommon words.

# Complexity
- Time complexity: $$O(n+m)$$

- Space complexity: $$O(n+m)$$

# Code
```cpp []
class Solution {
public:
    vector<string> uncommonFromSentences(string s1, string s2) {
        unordered_map <string,int> mop1, mop2;
        vector<string>a,b,d;
        s1+=' ';s2+=' ';
        for (int i=0;i<s1.size();i++){
            string x="";
            while (s1[i]!=' '){x+=s1[i];i++;}a.push_back(x);}
        for (int i=0;i<s2.size();i++){
            string x="";
            while (s2[i]!=' '){x+=s2[i];i++;}b.push_back(x);
        }
        for (int i=0;i<a.size();i++){mop1[a[i]]++;}
        for (int i=0;i<b.size();i++){mop2[b[i]]++;}
        for (auto &it:mop1){
            bool be=true;
            if (it.second==1){
                for (auto &jt:mop2){
                    if (jt.first==it.first){be=false;break;}
                }
                if (be){d.push_back(it.first);}
            }
        }
        for (auto &it:mop2){
            bool be=true;
            if (it.second==1){
                for (auto &jt:mop1){
                    if (jt.first==it.first){be=false;break;}
                }
                if (be){d.push_back(it.first);}
            }
        }
        return d;
    }
};
```
['C++']