Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <unordered_map>
- using namespace std;
- int countConsistentStrings(string allowed, vector<string>& words) {
- bool flg = true;
- int counter = 0;
- unordered_map<char,int>mp;
- for (auto a : allowed) {
- mp[a]++;
- }
- for (auto word : words) {
- flg = true;
- for (auto ch : word) {
- if (mp[ch] == 0) {
- flg = false;
- }
- }
- if (flg == true) counter++;
- }
- return counter;
- }
- int main()
- {
- string allowed = "abc";
- vector<string>words = { "a","b","c","ab","ac","bc","abc" };
- cout << countConsistentStrings(allowed, words);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement