Skip to content

Commit

Permalink
Create 1684. Count the Number of Consistent Strings (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Sep 12, 2024
2 parents 32f8aa7 + 88a29c8 commit 6facfc8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 1684. Count the Number of Consistent Strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution {
public:
int countConsistentStrings(string allowed, vector<string>& words) {
set<char> ans;
for (auto it : allowed) {
ans.insert(it);
}
int count = 0;
for (int i = 0; i < words.size(); i++) {
bool f1 = true;
for (auto it : words[i]) {
if (ans.find(it) == ans.end()) {
f1 = false;
break;
}
}
if (f1) {
count++;
}
}
return count;
}
};

0 comments on commit 6facfc8

Please sign in to comment.