Ctrl K

Words Despite Dead Keys

Easy
Some letter keys on a keyboard have stopped working; they are listed in the string dead_keys (no repeats). All other keys, including the space bar, work fine. You need to type the text text: words of lowercase English letters separated by exactly one space, with no spaces at the start or end. Return how many words of the text can be typed in full.
Example 1
text="quick brown fox", dead_keys="ox" → 1

brown has an o, and fox has both o and x. Only quick can be typed.

Example 2
text="tea time", dead_keys="" → 2

Every key works, so both words can be typed.

Example 3
text="ice cream", dead_keys="e" → 0

Both words contain an e.

Constraints
  • 1 ≤ len(text) ≤ 10⁴
  • 0 ≤ len(dead_keys) ≤ 26
  • text consists of lowercase English letters with single spaces between words
  • dead_keys consists of distinct lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySame Letter Cipher EasySame Letters, Reshuffled EasySame When Flipped EasyShuffle Into a Palindrome Easy
loading Python…
Input
text="quick brown fox", dead_keys="ox"
Expected
1

Run checks the first 3 tests in your browser. Submit checks all 132 tests on the server, hidden ones included.