1
# Runtime: 851 ms (Top 55.45%) | Memory: 16.4 MB (Top 32.26%)3
def numMatchingSubseq(self, s: str, words: List[str]) -> int:4
word_dict = defaultdict(list)6
# add words into bucket with key as order of the first letter8
word_dict[ord(w[0]) - ord("a")].append(w)9
# loop through the characters in s11
qualified = word_dict[ord(c) - ord("a")]12
word_dict[ord(c) - ord("a")] = []14
# if the word starts with the specified letter. i.e this is the last letter of the word18
word_dict[ord(q[1]) - ord("a")].append(q[1:])