100 % Beats | 2ms Solution | HashMap | Java
Code\njava []\nclass Solution {\n    public String[] uncommonFromSentences(String s1, String s2) {\n        Map<String, Integer> map = new HashMap<>();\n\n     
# Code\n```java []\nclass Solution {\n    public String[] uncommonFromSentences(String s1, String s2) {\n        Map<String, Integer> map = new HashMap<>();\n\n        for(String str : s1.split(" ")) {\n            map.put(str, map.getOrDefault(str, 0) + 1);\n        }\n\n        for(String str : s2.split(" ")) {\n            map.put(str, map.getOrDefault(str, 0) + 1);\n        }\n\n        int count = 0;\n        for (String key : map.keySet()) {\n            if(map.get(key) == 1) count++;\n        }\n\n        String result[] = new String[count];\n\n        int ind = 0;\n        for (String key : map.keySet()) {\n            if(map.get(key) == 1) result[ind++] = key;\n        }\n\n        return result;\n    }\n}\n```
['Java']