Maximum Number of Words You Can Type

给一个string和一个char数组, 表示坏的键盘的字符, 问能组成几个string的word.

class Solution {
    public int canBeTypedWords(String text, String brokenLetters) {
        String[] strs = text.split(" ");
        int res = 0;
        Set<Character> set = new HashSet<>();
        for(char c : brokenLetters.toCharArray())
            set.add(c);
        for(String s : strs){
            boolean add = true;
            for(char c : s.toCharArray())
                if(set.contains(c)){
                    add = false;
                    break;
                }
            if(add)
                res++;
        }
        return res;
    }
}