# [1684. Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings/description/) :::spoiler Hint ```cpp= ``` ::: :::spoiler Solution ```cpp= class Solution { public: int countConsistentStrings(string allowed, vector<string>& words) { unordered_set<int> st(allowed.begin(), allowed.end()); int cnt = words.size(); for (auto word : words) { for (auto w : word) { if (!st.count(w)) { cnt--; break; } } } return cnt; } }; ``` - T: $O(m + n \cdot k)$ - S: $O(m)$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up