A sentence is a string of single-space separated words where each word consists only of lowercase letters.

A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.

Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.

&nbsp;
Example 1:
Input: s1 = "this apple is sweet", s2 = "this apple is sour"
Output: ["sweet","sour"]
Example 2:
Input: s1 = "apple apple", s2 = "banana"
Output: ["banana"]

&nbsp;
Constraints:


	1 &lt;= s1.length, s2.length &lt;= 200
	s1 and s2 consist of lowercase English letters and spaces.
	s1 and s2 do not have leading or trailing spaces.
	All the words in s1 and s2 are separated by a single space.


from collections import Counter
class Solution:
    def uncommonFromSentences(self, s1: str, s2: str) -> List[str]:
        x = dict(Counter(s1.split() + s2.split()))
        ans = []
        for key in x:
            if x[key] == 1:
                ans.append(key)
                
        return ans
class Solution {
    public String[] uncommonFromSentences(String s1, String s2) {
        List<String> list=new LinkedList<>();
        Map<String, Integer> map=new HashMap<>();
        String[] arr1=s1.split(" ");
        String[] arr2=s2.split(" ");
        for(int i=0;i<arr1.length;i++){
            map.put(arr1[i],map.getOrDefault(arr1[i],0)+1);
        }
        for(int i=0;i<arr2.length;i++){
            map.put(arr2[i],map.getOrDefault(arr2[i],0)+1);
        }
        for(Map.Entry<String, Integer> entry:map.entrySet()){
            if(entry.getValue()==1)
                list.add(entry.getKey());
        }
        String[] res=new String[list.size()];
        for(int i=0;i<res.length;i++){
            res[i]=list.get(i);
        }
        return res;
    }
}
class Solution {
public:
    void uncommon(string s,unordered_map<string,int>&mp) {
        string word="";
        for(int i=0; i<s.size(); i++) {
                if(s[i]==' ') {
                     mp[word]++;
                     word="";
                }else {
                     word+=s[i];
                }
        }
        mp[word]++;
    }
    vector<string> uncommonFromSentences(string s1, string s2) {
        vector<string> ans;
        unordered_map<string,int> mp;
        uncommon(s1,mp);
        uncommon(s2,mp);
        for(pair<string,int> p : mp) {
            if(p.second==1) ans.push_back(p.first);
        }
        return ans;
    }
};
var uncommonFromSentences = function(s1, s2) {
    return (s1+' '+s2).split(' ').filter((el,i,arr)=>arr.indexOf(el)===arr.lastIndexOf(el))
};
Uncommon Words from Two Sentences