Maximum Number of Words You Can Type

A keyboard is malfunctioning: some letter keys do not work, while every other key works normally. Given a string `text` of words separated by single spaces (no leading or trailing spaces) and a string `brokenLetters` of all the distinct broken letter keys, return the number of words in `text` that you can type completely on this keyboard.

30:00

Maximum Number of Words You Can Type
easy
Free written solution
Topics
Companies

A keyboard is malfunctioning: some letter keys do not work, while every other key works normally.

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

Example 1:
Input: {"text":"hello world","brokenLetters":"ad"}
Output: 1
Constraints:
  • 1≤text.length≤1041 \leq \text{text.length} \leq 10^4

  • 0≤brokenLetters.length≤260 \leq \text{brokenLetters.length} \leq 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.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"text":"hello world","brokenLetters":"ad"}

Mark the broken keys 'a', 'd' in a set. A word is typeable only if none of its letters is in that set.

keyboard (cracked keys are broken)

q
w
e
r
t
y
u
i
o
p
a
s
d
f
g
h
j
k
l
z
x
c
v
b
n
m

typing the current word

waiting

words in text

hello
world

count = 0

Variables
VariableValue
brokenad
count0
DepthFunction Call
Stack empty
0/5