class Solution {
public:
int countConsistentStrings(string allowed, vector<string>& words) {
int n1=allowed.size();
int n2=words.size();
int ans=0;
for(int i=0;i<n2;i++)
{
int n3=words[i].size();
int ci=0;
for(int j=0;j<n3;j++)
{
bool f=false;
for(int k=0;k<n1;k++)
{
if(words[i][j]==allowed[k])
{
f=true;
break;
}
}
if(f==true) ci++;
}
if(ci==n3) ans++;
}
return ans;
}
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter