✅CPP | Unordered_map
\n\n## Intuition\nThe problem is to find words that are uncommon between two sentences. A word is considered uncommon if it appears exactly once in one of the s
\n\n## Intuition\nThe problem is to find words that are uncommon between two sentences. A word is considered uncommon if it appears exactly once in one of the sentences and doesn\'t appear in the other. The initial thought is to treat both sentences as a collection of words and count how many times each word appears. The words that appear exactly once across both sentences should be returned as the result.\n\n## Approach\n1. **Count Frequency of Words**: \n   - First, we traverse through both sentences, `s1` and `s2`, and split them into words. \n   - For each word, we store its frequency using a hash map (`unordered_map<string, int>`), where the key is the word, and the value is its occurrence count.\n   \n2. **Process Both Sentences**: \n   - We loop through the first sentence `s1` and extract words by splitting at spaces, updating the word count in the hash map.\n   - Then, we repeat the same process for the second sentence `s2`.\n\n3. **Find Uncommon Words**:\n   - After processing both sentences, we iterate through the hash map to find words that have a count of exactly 1, meaning they appear only once across both sentences.\n   - These words are then added to the result list.\n\n4. **Return the Result**:\n   - The result is the list of words that occur exactly once across the two sentences.\n\n## Complexity\n\n- **Time Complexity**: O(n + m)\n   - Where `n` is the length of the first sentence and `m` is the length of the second sentence. We traverse through both sentences once and update the hash map.\n  \n- **Space Complexity**: O(n)\n   - We use a hash map to store the count of unique words, so the space complexity depends on the number of distinct words.\n\n## Code\n```cpp\nclass Solution {\npublic:\n    vector<string> uncommonFromSentences(string s1, string s2) {\n        vector<string> ans;\n        int n = s1.size();\n        int m = s2.size();\n        unordered_map<string,int> temp;\n        string str="";\n\n        // Process first sentence (s1)\n        for(int i=0; i<n; i++) {\n            if(s1[i] == \' \') {\n                temp[str]++;\n                str = "";\n            } else {\n                str += s1[i];\n                if(i == n-1) {\n                    temp[str]++;\n                    str = "";\n                }\n            }\n        }\n\n        // Process second sentence (s2)\n        for(int i=0; i<m; i++) {\n            if(s2[i] == \' \') {\n                temp[str]++;\n                str = "";\n            } else {\n                str += s2[i];\n                if(i == m-1) {\n                    temp[str]++;\n                    str = "";\n                }\n            }\n        }\n\n        // Collect uncommon words (frequency = 1)\n        for(auto it: temp) {\n            if(it.second == 1) {\n                ans.push_back(it.first);\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']