1684. 统计一致字符串的数目
class Solution {
public int countConsistentStrings(String allowed, String[] words) {
int[] flag = new int[30];
char[] all = allowed.toCharArray();
for(int i = 0; i < all.length; i ++) {
int index = all[i] - 'a';
flag[index] = 1;
}
int res = 0;
for(String word : words) {
boolean f = true;
for(int i = 0; i < word.length(); i ++) {
int index = word.charAt(i) - 'a';
if(flag[index] != 1) {
f = false;
break;
}
}
if(f) res ++;
}
return res;
}
}