-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1684.cpp
More file actions
34 lines (26 loc) · 814 Bytes
/
1684.cpp
File metadata and controls
34 lines (26 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<vector>
int countConsistentStrings(std::string allowed, std::vector<std::string>& words) {
int count = 0;
for (int i = 0; i < words.size(); ++i) {
bool check = true;
for (int j = 0; j < words[i].size(); ++j) {
if (allowed.find(words[i][j]) == std::string::npos) {
check = false;
break;
}
}
if (check) {
++count;
}
}
return count;
}
int main() {
// std::string allowed = "abc";
// std::vector<std::string> words = { "a","b","c","ab","ac","bc","abc" };
std::string allowed = "cad";
std::vector<std::string> words = { "cc","acd","b","ba","bac","bad","ac","d" };
std::cout << countConsistentStrings(allowed, words);
std::cin.get();
}