Problem
Qn - Maximum Number of Words You Can Type
Approach
Pretty simple question, the thing I learnt here is the use of any to check for a True in an array. Something like this any([False, False, True]) will return True.
Complexity
- Time:
- Space:
Code
class Solution:
def canBeTypedWords(self, text: str, brokenLetters: str) -> int:
setBroken = set(brokenLetters)
words = text.split()
return sum(not any(c in setBroken for c in word) for word in words)