Count the Number of Consistent Strings

给一个字符串allowed和一个字符串组words, 问words里面是不是由allowed里的字符组成.

查存在用set

class Solution {
    public int countConsistentStrings(String allowed, String[] words) {
        Set<Character> set = new HashSet<>();
        for(char c :allowed.toCharArray())
            set.add(c);
        int count = 0;
        for(String w : words) {
            boolean all = true;
            for(char c : w.toCharArray()) {
                if(!set.contains(c)){
                    all = false;
                    break;
                }
            }
            if(all)
                count++;
        }
        return count;
    }
}