Skip to content

Commit 6facfc8

Browse files
authored
Create 1684. Count the Number of Consistent Strings (#583)
2 parents 32f8aa7 + 88a29c8 commit 6facfc8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution {
2+
public:
3+
int countConsistentStrings(string allowed, vector<string>& words) {
4+
set<char> ans;
5+
for (auto it : allowed) {
6+
ans.insert(it);
7+
}
8+
int count = 0;
9+
for (int i = 0; i < words.size(); i++) {
10+
bool f1 = true;
11+
for (auto it : words[i]) {
12+
if (ans.find(it) == ans.end()) {
13+
f1 = false;
14+
break;
15+
}
16+
}
17+
if (f1) {
18+
count++;
19+
}
20+
}
21+
return count;
22+
}
23+
};

0 commit comments

Comments
 (0)