<p>Given a string array <code>words</code>, return <em>an array of all characters that show up in all strings within the </em><code>words</code><em> (including duplicates)</em>. You may return the answer in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> words = ["bella","label","roller"]
<strong>Output:</strong> ["e","l","l"]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> words = ["cool","lock","cook"]
<strong>Output:</strong> ["c","o"]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= words.length &lt;= 100</code></li>
	<li><code>1 &lt;= words[i].length &lt;= 100</code></li>
	<li><code>words[i]</code> consists of lowercase English letters.</li>
</ul>

class Solution {
public:
    vector<string> commonChars(vector<string>& words) {
        unordered_map<char,int> um;
        unordered_map<char,int> mp;
        vector<string> ans;
        int n=words.size();
        for(char x:words[0]){
            if(um.find(x)==um.end()){
                um[x]=1;
            }
            else um[x]++;
        }
        for(int i=1;i<n;i++){
            for(char c:words[i]){
                if(i%2!=0){
                    if(um.find(c)!=um.end() && um[c]!=0){
                        um[c]--;
                        if(mp.find(c)==mp.end()){
                            mp[c]=1;
                        }
                        else mp[c]++;
                    }
                }
                else{
                    if(mp.find(c)!=mp.end() && mp[c]!=0){
                        mp[c]--;
                        if(um.find(c)==um.end()){
                            um[c]=1;
                        }
                        else um[c]++;
                    }
                }
            }
            if(i%2==0){
                mp.clear();
            }
            else{
                um.clear();
            }
        }
        if((n-1)%2==0){
            for(pair<char,int> p:um){
                cout<<p.first<<" "<<p.second;
                int n=p.second;
                while(n--) ans.push_back(string(1,p.first));
            }
        }
        else{
            for(pair<char,int> p:mp){
                int n=p.second;
                while(n--) ans.push_back(string(1,p.first));
            }
        }
        return ans;
    }
};
13000