vector<string> commonChars(vector<string>& words) {
int count[words.size()][26] = {};
//getting error
//error: variable-sized object may not be initialized
string ele;
vector<string> result;
for(int s1=0; s1<words.size(); s1++){
for(int s2=0; s2<words[s1].size(); s2++){
count[s1][words[s1][s2]-97]++;
}
}
for(int s=0; s<26; s++){
int small = count[0][s];
for(int i=1; i<words.size(); i++){
small = min(small, count[i][s]);
}
while(small-- > 0){
ele = (char)(s+97);
result.push_back(ele);
}
}
return result;
}
On the line int count[words.size()][26] = {};
error: variable-sized object may not be initialized
Can anyone help me? What is this error?