class Solution {
public:
vector<string> commonChars(vector<string>& words) {
vector<string> result;
vector<vector<int>> map(words.size() , vector<int>(26,0));
for(int i=0 ; i<words.size() ;i++)
{
for(int j=0 ; j<words[i].size() ;j++)
map[i][words[i][j] - 'a'] += 1;
}
for(int j=0 ; j<26 ;j++)
{
int tmp = INT_MAX;
for(int i=0 ; i<words.size() ;i++)
{
if(map[i][j] == 0 ) break;
tmp = min( tmp, map[i][j]);
if(i==words.size()-1)
{
while(tmp--)
{
string s(1,'a'+j);
result.push_back(s);
}
}
}
}
return result;
}
};