Untitled
unknown
plain_text
a year ago
565 B
10
Indexable
class Solution {
public:
int countConsistentStrings(string allowed, vector<string>& words) {
unordered_map < int, bool > seen;
int ans = 0;
for(int i=0;i<allowed.size();i++) {
seen[allowed[i] - 'a'] = true;
}
for(int i=0;i<words.size();i++) {
int cnt = 0, sz = words[i].size();
for(int j=0;j<sz;j++) {
if(seen[words[i][j] - 'a'])cnt++;
}
if(sz == cnt)ans++;
}
return ans;
}
};Editor is loading...
Leave a Comment