A coastal telegraph station took storm damage overnight, and a handful of letter keys on its transmitter panel have jammed solid: pressing any of them does nothing. The operator's logbook holds one dispatch, a line of lowercase words separated by single spaces. A word can still be sent in full only if none of its letters need a jammed key; a single jammed letter anywhere in a word means the whole word must be dropped. Count how many words in the dispatch can still be transmitted in full.
Print a single integer: the number of words in the dispatch that contain no jammed letter.
Example 1
Input
hello world ad
Expected
1
Explanation
"hello" uses only h, e, l, o, none of which is in the jammed set {a, d}, so it can still be sent. "world" contains 'd', a jammed key, so it is dropped. Exactly 1 word survives.
Example 2
Input
leet code lt
Expected
1
Explanation
"leet" contains both jammed letters 'l' and 't', so it is dropped. "code" contains neither 'l' nor 't', so it survives. Exactly 1 word can still be sent.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →