You are viewing a single comment's thread. Return to all comments →
Nice logic. I modified your logic a bit. First deleted all the repeated elements and them made the comparison. C++ code
int alpha[26] = {0}; int cnt = 0; vector <string> str(N); for(int i = 0; i < N; i++) { cin >> str[i]; sort(str[i].begin(), str[i].end()); str[i].erase(unique(str[i].begin(), str[i].end()), str[i].end()); for(int k = 0; k < str[i].size(); k++) { char c = str[i].at(k); alpha[c - 'a']++; if(alpha[c - 'a'] == N) cnt++; } }
Gemstones
You are viewing a single comment's thread. Return to all comments →
Nice logic. I modified your logic a bit. First deleted all the repeated elements and them made the comparison. C++ code