class Solution {
public String[] uncommonFromSentences(String s1, String s2) {
String[] s1Array = s1.split(" "), s2Array = s2.split(" ");
Map<String, Integer> s1Map = new HashMap<>(), s2Map = new HashMap<>();
for (String str: s1Array) s1Map.put(str, s1Map.getOrDefault(str, 0) + 1);
for (String str: s2Array) s2Map.put(str, s2Map.getOrDefault(str, 0) + 1);
int sz = 0;
for (String key: s1Map.keySet()) if (s1Map.get(key) == 1 && s2Map.containsKey(key) == false) sz++;
for (String key: s2Map.keySet()) if (s2Map.get(key) == 1 && s1Map.containsKey(key) == false) sz++;
String[] ans = new String[sz];
int ptr = 0;
for (String key: s1Map.keySet()) if (s1Map.get(key) == 1 && s2Map.containsKey(key) == false) ans[ptr++] = key;
for (String key: s2Map.keySet()) if (s2Map.get(key) == 1 && s1Map.containsKey(key) == false) ans[ptr++] = key;
return ans;
}
}