Prefix count queries
Your task
Given a list of words (possibly with duplicates) and a list of query strings, return for each query the number of words that have the query as a prefix. Build a trie where each node stores a counter of how many inserted words pass through it; then each query walks down the trie and reads the counter at its terminal node (0 if the path breaks). Return the list of prefix counts in query order.
Examples
prefix_count(words: list[str], queries: list[str]) -> list[int]Example 1
Input
prefix_count(["apple", "app", "apricot", "banana"], ["ap", "app", "b", "xyz", "apple"])Output
[3, 2, 1, 0, 1]