[C++/Java/Python] Easy Solution with Explanation
Intuition:\nNo matter how many sentences,\nuncommon word = words that appears only once\n\nI recall another similar problem:\n819. Most Common Word\nSo I open m
**Intuition**:\nNo matter how many sentences,\n**uncommon word = words that appears only once**\n\nI recall another similar problem:\n[819. Most Common Word](https://leetcode.com/problems/most-common-word/discuss/123854/)\nSo I open my solutions there and copy some codes.\n\n**Explanation**:\n\nTwo steps:\nCount words occurrence to a HashMap<string, int> `count`.\nLoop on the hashmap, find words that appears only once.\n\n**C++:**\n```\n    vector<string> uncommonFromSentences(string A, string B) {\n        unordered_map<string, int> count;\n        istringstream iss(A + " " + B);\n        while (iss >> A) count[A]++;\n        vector<string> res;\n        for (auto w: count)\n            if (w.second == 1)\n                res.push_back(w.first);\n        return res;\n    }\n```\n\n**Java:**\n```\n    public String[] uncommonFromSentences(String A, String B) {\n        Map<String, Integer> count = new HashMap<>();\n        for (String w : (A + " " + B).split(" "))\n            count.put(w, count.getOrDefault(w, 0) + 1);\n        ArrayList<String> res = new ArrayList<>();\n        for (String w : count.keySet())\n            if (count.get(w) == 1)\n                res.add(w);\n        return res.toArray(new String[0]);\n    }\n```\n**Python:**\n```\n    def uncommonFromSentences(self, A, B):\n        c = collections.Counter((A + " " + B).split())\n        return [w for w in c if c[w] == 1]\n```\n
[]