Prefix word count

Write codeMedium20 minAmazon and Google style

Your task

Build a trie from the list words (duplicates allowed and counted separately). Then for each query prefix, return how many words in the collection start with that prefix. The empty-string prefix matches every word. Words and prefixes contain only lowercase letters. Return the list of counts in query order.

Examples

trie_prefix_counts(words: list[str], prefixes: list[str]) -> list[int]
Example 1
Inputtrie_prefix_counts(["apple", "app", "apricot", "banana"], ["app", "ap", "b", "xyz", ""])
Output[2, 3, 1, 0, 4]