There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.

Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.

&nbsp;
Example 1:

Input: text = "hello world", brokenLetters = "ad"
Output: 1
Explanation: We cannot type "world" because the 'd' key is broken.


Example 2:

Input: text = "leet code", brokenLetters = "lt"
Output: 1
Explanation: We cannot type "leet" because the 'l' and 't' keys are broken.


Example 3:

Input: text = "leet code", brokenLetters = "e"
Output: 0
Explanation: We cannot type either word because the 'e' key is broken.


&nbsp;
Constraints:


	1 &lt;= text.length &lt;= 104
	0 &lt;= brokenLetters.length &lt;= 26
	text consists of words separated by a single space without any leading or trailing spaces.
	Each word only consists of lowercase English letters.
	brokenLetters consists of distinct lowercase English letters.


class Solution:
    def canBeTypedWords(self, text: str, brokenLetters: str) -> int:
        text = text.split()
        length = len(text)
        brokenLetters = set(brokenLetters)

        for word in text:
            for char in word:
                if char in brokenLetters:
                    length -= 1
                    break
					
        return length
class Solution {
    public int canBeTypedWords(String text, String brokenLetters) {
        int count = 1;
        boolean isBad = false;
        for (char c : text.toCharArray()) {
            if (c == ' ') {
                isBad = false;
                count++;
            } else {
                if (!isBad && brokenLetters.indexOf(c) != -1) {
                    isBad = true;
                    count--;
                }
            }
        }
        return count;
    }
}
class Solution {
public:
    int canBeTypedWords(string text, string brokenLetters) {
        vector<int> ch(26,0);
		// store the broken letters in ch vector
        for(char c: brokenLetters){
            ch[c-'a']=1;
        }
        int cnt=0,ans=0;
		//traversing the text string
        for(int i=0;i<text.length();i++){
		    //if char is ' ' means that we got a new word
            if(text[i]==' '){
			    // cnt remain 0 means that there is no broken letter in this word
                if(cnt==0) ans++;
                cnt=0; //reinitialize cnt to 0 as new word start from here
            }else if(ch[text[i]-'a']==1){ //if char is present in ch then just increment the cnt
                    cnt++;
            }
        }
		//for last word in string
        if(cnt==0) ans++;
        return ans;
    }
};
var canBeTypedWords = function(text, brokenLetters) {
    let regexp="["+brokenLetters+"]\+"
    let word=text.split(" "), count=0;
    for(let i=0; i<word.length; i++){
        let work=true;
        // if matches, means word[i] contains malfunction letters.
        if(word[i].match(regexp)){work=false};
        if(work){count++};
    }
    return count;
};
Maximum Number of Words You Can Type